From 23bfb6baed975b8214f40adec28554766a1aa253 Mon Sep 17 00:00:00 2001 From: Eyal Alon <3756641+soyeyalon@users.noreply.github.com> Date: Tue, 1 Dec 2026 18:51:39 +0200 Subject: [PATCH 1/7] build(domql-net): depend on DOMQL 1.0.0-preview.4 The package depends on formaui-net.DOMQL 1.0.0-preview.4, which serves the bundle its browser module imports. CI runs the gate on every push and pull request, against a DOMQL checkout at that release's tag; a push to candidate runs the full gate and keeps the package. --- .github/workflows/ci.yml | 78 ++++++++++++++++++++++ CHANGELOG.md | 2 +- README.md | 2 +- docs/decisions.md | 2 +- docs/features-status.md | 5 +- src/Forma.DOMQL.NET/Forma.DOMQL.NET.csproj | 2 + 6 files changed, 85 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/ci.yml 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/CHANGELOG.md b/CHANGELOG.md index 9efe83b..b1ba982 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,4 +12,4 @@ Each release of DOMQL.NET's package, `formaui-net.DOMQL.NET`, newest first, with *Unreleased · DOMQL `1.0.0-preview.4`* - 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. +- 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.4`, which serves that bundle, and on Microsoft.JSInterop. diff --git a/README.md b/README.md index c75d3cf..002c9ba 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, unreleased.** DOMQL.NET's first preview, `1.0.0-preview.1`, runs over the connection DOMQL's release `1.0.0-preview.4` brings, which its package depends on. See [the status](docs/features-status.md). ```csharp builder.Services.AddDomql(); diff --git a/docs/decisions.md b/docs/decisions.md index b3d33c8..de9bb1b 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -39,7 +39,7 @@ 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. diff --git a/docs/features-status.md b/docs/features-status.md index cf39b69..2b9196c 100644 --- a/docs/features-status.md +++ b/docs/features-status.md @@ -1,6 +1,6 @@ # 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`, unreleased.** It implements [its specification](../spec/README.md) on DOMQL's connection, which DOMQL `1.0.0-preview.4` introduces. Its package depends on DOMQL's, `formaui-net.DOMQL`, from that release, and CI runs its gate against a DOMQL checkout at that release's tag. | Feature | Contract | State | | --- | --- | --- | @@ -17,7 +17,6 @@ | 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` | +| The release and promotion workflows, as DOMQL's, and the repository's rules for `main` | The owner's go, as they publish to nuget.org and change the repository's settings | | 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/src/Forma.DOMQL.NET/Forma.DOMQL.NET.csproj b/src/Forma.DOMQL.NET/Forma.DOMQL.NET.csproj index 20d57ec..0a9f5c2 100644 --- a/src/Forma.DOMQL.NET/Forma.DOMQL.NET.csproj +++ b/src/Forma.DOMQL.NET/Forma.DOMQL.NET.csproj @@ -29,6 +29,8 @@ + + From 5d8331c53ec515b938db4fce46c66870e1e209c7 Mon Sep 17 00:00:00 2001 From: Eyal Alon <3756641+soyeyalon@users.noreply.github.com> Date: Thu, 3 Dec 2026 03:45:45 +0200 Subject: [PATCH 2/7] fix(domql-net): take deliveries in crossing order A batch's handlers ran one after another, each awaited before the next delivery was taken. 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, while handlers of different batches never waited for each other. Batches are now taken in the order they cross, a streamed one read before any after it, and each delivery at its place: a watch's change applied, a value settled, an event's handler started, none waiting for a handler to complete. A batch is still answered once its handlers have. A delivery that names no handle by a number is answered with null rather than rejecting its batch, and a batch that can't be read or is rejected leaves every copy uncertain until its snapshot arrives. D3 records it. --- CHANGELOG.md | 1 + docs/decisions.md | 21 +++ docs/design.md | 6 +- docs/features-status.md | 1 + spec/README.md | 7 +- src/Forma.DOMQL.NET/DomqlConnection.cs | 117 +++++++++++--- src/Forma.DOMQL.NET/DomqlOwner.cs | 5 +- src/Forma.DOMQL.NET/DomqlRoute.cs | 7 + src/Forma.DOMQL.NET/DomqlSubscription.cs | 4 +- src/Forma.DOMQL.NET/DomqlWatch.cs | 4 +- .../DomqlConnectionTests.cs | 146 ++++++++++++++++++ tests/Forma.DOMQL.NET.Tests/FakeBrowser.cs | 17 +- 12 files changed, 300 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1ba982..2b2ee53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,4 +12,5 @@ Each release of DOMQL.NET's package, `formaui-net.DOMQL.NET`, newest first, with *Unreleased · DOMQL `1.0.0-preview.4`* - 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. +- 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.4`, which serves that bundle, and on Microsoft.JSInterop. diff --git a/docs/decisions.md b/docs/decisions.md index de9bb1b..1ca4542 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -45,3 +45,24 @@ Each decision taken without stopping to ask, with why and what was declined, for - 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 + +*December 3, 2026* + +- **Kind:** Contract, refining how [D1](#d1) takes a batch's deliveries. +- **Decision:** + - 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:** + - 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. + - Taken in the order they crossed, deliveries 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 is answered with its batch's events. diff --git a/docs/design.md b/docs/design.md index af97b80..4c28955 100644 --- a/docs/design.md +++ b/docs/design.md @@ -19,14 +19,16 @@ How DOMQL.NET is built to meet [its specification](../spec/README.md). It is DOM ## 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 every delivery applies in the order it crossed, as [D3](decisions.md#d3) records. +- **What a handler still holds.** A batch is answered once its handlers have completed, so a watch whose change shares a batch with a handler awaiting a dialog sends its next change only once the dialog closes. - **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 2b9196c..a280ff8 100644 --- a/docs/features-status.md +++ b/docs/features-status.md @@ -8,6 +8,7 @@ | 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 | +| 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 | diff --git a/spec/README.md b/spec/README.md index 19841fa..a3e8e70 100644 --- a/spec/README.md +++ b/spec/README.md @@ -80,7 +80,7 @@ A **`DomqlWatch`** keeps a copy of its query's result, which each delivery br - **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. +- **The browser's next change set** crosses once the batch this one crossed in is answered, 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.4/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. - **`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,7 +91,8 @@ 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. +- **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.4/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. @@ -118,6 +119,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. 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 ReceiveAsync(DomqlTransfer transfer) + { + // The batch claims its place first, so batches received at once, as a runtime that calls back on more than one thread delivers them, are taken in the order they were received. + var taken = new TaskCompletionSource(); + var before = Interlocked.Exchange(ref _taken, taken.Task); + + try + { + (object?[] Answers, Task Handled) took; + + try + { + took = await TakeAsync(before, transfer).ConfigureAwait(true); + } + finally + { + taken.SetResult(); + } + + await took.Handled.ConfigureAwait(true); + + return took.Answers; + } + catch (Exception error) when (error is not OutOfMemoryException) + { + // A batch the browser hears rejected leaves its watches waiting for a refresh, which every watch is given, its copy uncertain until its snapshot arrives. + Unsettle(); + + throw; + } + } + + /// + /// Reads a batch, then takes it once the batch before it has been taken, so batches are taken in the order they crossed, one that crosses as a stream among them. Each delivery is taken at its place: a + /// watch's change applied, an operation'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. Answers the batch's answers, and what completes once its handlers have. A delivery to a handle that has ended, by then, is answered with null and goes no further. + /// + private async Task<(object?[] Answers, Task Handled)> TakeAsync(Task before, DomqlTransfer transfer) { JsonDocument? read = null; JsonElement deliveries; @@ -228,31 +268,31 @@ internal Task SendAsync(DomqlRequest request) { read?.Dispose(); - // A batch that can't be read leaves every copy uncertain, so each watch delivers its snapshot whole; the batch is acknowledged, answering nothing. One refresh at a time: a batch that can't be - // read while one 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 leaves every copy uncertain; the batch is acknowledged, answering nothing. DomqlLog.BatchUnread(_logger, error); + Unsettle(); - if (!_isRefreshingUnread) - { - _isRefreshingUnread = true; - _ = RefreshQuietlyAsync(); - } + // Taken in its turn all the same, so no batch after it is taken before one before it. + await before.ConfigureAwait(true); - return []; + return ([], Task.CompletedTask); } - _isRefreshingUnread = false; - using var reading = read; + await before.ConfigureAwait(true); + + _isRefreshingUnread = false; + var answers = new object?[deliveries.GetArrayLength()]; + List? handlers = null; var index = 0; foreach (var delivery in deliveries.EnumerateArray()) { IDomqlRoute? handle = null; - if (delivery.TryGetProperty("handle", out var id) && id.TryGetInt64(out var handleId)) + if (delivery.ValueKind == JsonValueKind.Object && delivery.TryGetProperty("handle", out var id) && id.ValueKind == JsonValueKind.Number && id.TryGetInt64(out var handleId)) { lock (_gate) { @@ -262,21 +302,56 @@ internal Task SendAsync(DomqlRequest request) if (handle is not null) { - try - { - answers[index] = await handle.DeliverAsync(delivery.Clone()).ConfigureAwait(true); - } - catch (Exception error) when (error is not OutOfMemoryException) + var delivered = DeliverAsync(handle, delivery.Clone(), answers, index); + + if (!delivered.IsCompletedSuccessfully) { - // A handler's failure stays its own: the batch is acknowledged, and the deliveries after it applied. - DomqlLog.HandlerFailed(_logger, handle.Id, error); + (handlers ??= []).Add(delivered); } } index++; } - return answers; + return (answers, handlers is null ? Task.CompletedTask : Task.WhenAll(handlers)); + } + + /// + /// Leaves every watch's copy uncertain, so each skips change sets until its snapshot whole arrives, which one refresh of every watch brings. One refresh at a time: a batch that can't be read while one is + /// under way, as a snapshot past the size the connection reads is, refreshes nothing more until a batch is read. + /// + private void Unsettle() + { + IDomqlWatch[] watches; + + lock (_gate) + { + watches = [.. _handles.Values.OfType()]; + } + + foreach (var watch in watches) + { + watch.MarkUncertain(); + } + + if (!_isRefreshingUnread) + { + _isRefreshingUnread = true; + _ = RefreshQuietlyAsync(); + } + } + + /// Takes a delivery, its answer kept at its place; a handler's failure stays its own, so the batch is acknowledged and the deliveries after it applied. + private async Task DeliverAsync(IDomqlRoute handle, JsonElement delivery, object?[] answers, int index) + { + try + { + answers[index] = await handle.DeliverAsync(delivery).ConfigureAwait(true); + } + catch (Exception error) when (error is not OutOfMemoryException) + { + DomqlLog.HandlerFailed(_logger, handle.Id, error); + } } /// Refreshes every watch, as a batch that can't be read asks, where the connection can still carry the request. diff --git a/src/Forma.DOMQL.NET/DomqlOwner.cs b/src/Forma.DOMQL.NET/DomqlOwner.cs index e369706..7645497 100644 --- a/src/Forma.DOMQL.NET/DomqlOwner.cs +++ b/src/Forma.DOMQL.NET/DomqlOwner.cs @@ -20,8 +20,9 @@ internal DomqlOwner(DomqlConnection connection, string name) internal DomqlConnection Connection { get; } /// - /// Watches a query: its first snapshot arrives with its request's answer, as waits for, and each change after it is applied to the watch's copy, the next one sent only - /// once the browser has heard it applied. is called with each result once it is applied, one call at a time, with the latest where several arrived meanwhile. + /// Watches a query: its first snapshot arrives with its request's answer, as waits for, and each change after it is applied to the watch's copy, the next one sent + /// only once the browser has heard the batch it crossed in answered. is called with each result once it is applied, one call at a time, with the latest where several arrived + /// meanwhile. /// public DomqlWatch Watch(DomqlQuery query, IReadOnlyDictionary? bindings = null, Func? changed = null, DomqlWatchOptions? options = null) { diff --git a/src/Forma.DOMQL.NET/DomqlRoute.cs b/src/Forma.DOMQL.NET/DomqlRoute.cs index 7f4df6e..f431d5e 100644 --- a/src/Forma.DOMQL.NET/DomqlRoute.cs +++ b/src/Forma.DOMQL.NET/DomqlRoute.cs @@ -18,6 +18,13 @@ internal interface IDomqlRoute void End(); } +/// A watch, as the connection reaches every watch it runs. +internal interface IDomqlWatch +{ + /// Leaves its copy uncertain, as a delivery it may have missed does: it skips change sets until its snapshot whole arrives. + void MarkUncertain(); +} + /// What every operation's requests and deliveries share: the fields a request names it by, and what an answer or a delivery holds. internal static class DomqlRouting { diff --git a/src/Forma.DOMQL.NET/DomqlSubscription.cs b/src/Forma.DOMQL.NET/DomqlSubscription.cs index c203944..9b5cb5e 100644 --- a/src/Forma.DOMQL.NET/DomqlSubscription.cs +++ b/src/Forma.DOMQL.NET/DomqlSubscription.cs @@ -3,8 +3,8 @@ namespace Domql; using System.Text.Json; /// -/// A subscription to an event source: each event the browser delivers is mapped onto and handed to its handler as it arrives, never behind another's acknowledgment; the event is -/// acknowledged in the browser once the handler has completed, with what it answers where the source declares answers. +/// A subscription to an event source: each event the browser delivers is mapped onto and handed to its handler as it is taken, in the order the batches crossed, never behind +/// another's acknowledgment or handler; the event is acknowledged in the browser once the handler has completed, with what it answers where the source declares answers. /// /// What each event maps onto. public sealed class DomqlSubscription : DomqlHandle diff --git a/src/Forma.DOMQL.NET/DomqlWatch.cs b/src/Forma.DOMQL.NET/DomqlWatch.cs index eec3f65..46aadce 100644 --- a/src/Forma.DOMQL.NET/DomqlWatch.cs +++ b/src/Forma.DOMQL.NET/DomqlWatch.cs @@ -24,7 +24,7 @@ public enum DomqlWatchStatus /// with its request's answer; a delivery that overtakes that answer waits for it. A change set that doesn't apply to the copy makes the copy uncertain, and the watch asks for its snapshot whole. /// /// What its result maps onto. -public sealed class DomqlWatch : DomqlHandle +public sealed class DomqlWatch : DomqlHandle, IDomqlWatch { private readonly DomqlQuery _query; private readonly Func? _changed; @@ -212,6 +212,8 @@ private void Apply(JsonElement delivery) } } + void IDomqlWatch.MarkUncertain() => _isUncertain = true; + private void Replace(JsonElement snapshot) { _copy = JsonNode.Parse(snapshot.GetRawText()); diff --git a/tests/Forma.DOMQL.NET.Tests/DomqlConnectionTests.cs b/tests/Forma.DOMQL.NET.Tests/DomqlConnectionTests.cs index d73f373..bba91c3 100644 --- a/tests/Forma.DOMQL.NET.Tests/DomqlConnectionTests.cs +++ b/tests/Forma.DOMQL.NET.Tests/DomqlConnectionTests.cs @@ -196,6 +196,122 @@ public Task Should_answer_an_event_with_its_handler_s_answer_once_the_handler_co Assert.False(subscription.IsDisposed); }); + [Fact] + public Task Should_take_each_delivery_at_its_place_so_a_handler_finds_the_state_before_its_event_and_none_waits_for_another() => _dispatcher.RunAsync(async () => + { + var slow = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var heard = new List(); + var watch = _owner.Watch(CountQuery, Bindings("focus")); + DomqlWatch? watched = null; + var subscription = _owner.Subscribe(DomqlQuery.Create("panel:presses()"), null, async (string press) => + { + heard.Add($"{press} sees {watched!.Current!.Count}"); + + if (press == "first") + { + await slow.Task; + } + + heard.Add($"{press} done"); + }); + var batch = await _browser.NextBatchAsync(); + var watchId = (long)batch.Requests[0]!["handle"]!; + var subscriptionId = (long)batch.Requests[1]!["handle"]!; + + watched = watch; + batch.Answer("""{"snapshot":{"count":1}}""", "{}"); + await watch.ReadyAsync(Token); + + // The first press's handler waits; the press after it starts at its place, before the change after it, and the change applies without waiting for either. + var first = _browser.DeliverAsync($$"""[{"handle":{{subscriptionId}},"generation":0,"event":"first"},{"handle":{{subscriptionId}},"generation":0,"event":"between"},{"handle":{{watchId}},"generation":0,"changes":[{"op":"replace","path":"/count","value":2}]}]"""); + + Assert.Equal(new Counted(2), watch.Current); + Assert.Equal(["first sees 1", "between sees 1", "between done"], heard); + + var second = _browser.DeliverAsync($$"""[{"handle":{{watchId}},"generation":0,"changes":[{"op":"replace","path":"/count","value":3}]},{"handle":{{subscriptionId}},"generation":0,"event":"second"}]"""); + + Assert.Equal("[null,null]", (await second).ToJsonString()); + Assert.Equal(new Counted(3), watch.Current); + Assert.Equal(["first sees 1", "between sees 1", "between done", "second sees 3", "second done"], heard); + Assert.False(first.IsCompleted); + + // The first batch is answered once its handlers have completed. + slow.SetResult(); + + Assert.Equal("[null,null,null]", (await first).ToJsonString()); + Assert.Equal("first done", heard[^1]); + Assert.False(subscription.IsDisposed); + }); + + [Fact] + public Task Should_take_a_batch_after_one_that_crossed_before_it_as_a_stream_still_being_read() => _dispatcher.RunAsync(async () => + { + var opened = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var watch = _owner.Watch(CountQuery); + var batch = await _browser.NextBatchAsync(); + var id = (long)batch.Requests[0]!["handle"]!; + + batch.Answer("""{"snapshot":{"count":1}}"""); + await watch.ReadyAsync(Token); + + var streamed = _browser.DeliverAsync($$"""[{"handle":{{id}},"generation":0,"changes":[{"op":"replace","path":"/count","value":2}]}]""", asStream: true, opened.Task); + var inline = _browser.DeliverAsync($$"""[{"handle":{{id}},"generation":0,"changes":[{"op":"replace","path":"/count","value":3}]}]"""); + + Assert.Equal(new Counted(1), watch.Current); + Assert.False(inline.IsCompleted); + + opened.SetResult(); + await streamed; + await inline; + + Assert.Equal(new Counted(3), watch.Current); + Assert.Null(watch.Error); + }); + + [Fact] + public Task Should_settle_a_result_and_hear_an_execution_s_failure_at_their_place_and_skip_a_handle_a_handler_before_it_ended() => _dispatcher.RunAsync(async () => + { + var slow = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var heard = new List(); + DomqlSubscription? later = null; + var first = _owner.Subscribe(DomqlQuery.Create("panel:presses()"), null, async (string press) => + { + heard.Add($"{press} starts"); + _ = later!.DisposeAsync().AsTask(); + await slow.Task; + heard.Add($"{press} ends"); + }); + + later = _owner.Subscribe(DomqlQuery.Create("panel:presses()"), null, (string press) => + { + heard.Add($"{press} starts"); + + return Task.CompletedTask; + }); + + var execution = _owner.Run(DomqlQuery.Create("""panel.ownClass({ name = "dragging" })"""), Bindings("panel"), new DomqlExecutionOptions { Failed = error => { heard.Add(error.Code); return Task.CompletedTask; } }); + var scrolled = _owner.ExecuteAsync(DomqlQuery.Create("""panel.scrollTo({ block = 300, behavior = "smooth" })"""), Bindings("panel"), Token); + var batch = await _browser.NextBatchAsync(); + var firstId = (long)batch.Requests[0]!["handle"]!; + var laterId = (long)batch.Requests[1]!["handle"]!; + var executionId = (long)batch.Requests[2]!["handle"]!; + var scrollingId = (long)batch.Requests[3]!["handle"]!; + + batch.Answer("{}", "{}", "{}", """{"pending":true}"""); + + var answered = _browser.DeliverAsync($$"""[{"handle":{{firstId}},"generation":0,"event":"one"},{"handle":{{laterId}},"generation":0,"event":"two"},{"handle":{{executionId}},"generation":0,"error":{"code":"DOMQL5016","kind":"evaluation","message":"gone"} },{"handle":{{scrollingId}},"value":true}]"""); + + Assert.True(await scrolled); + Assert.Equal(["one starts", "DOMQL5016"], heard); + + slow.SetResult(); + + Assert.Equal("[null,null,null,null]", (await answered).ToJsonString()); + Assert.Equal(["one starts", "DOMQL5016", "one ends"], heard); + Assert.True(later.IsDisposed); + Assert.False(execution.IsDisposed); + }); + [Fact] public Task Should_settle_an_execution_with_its_answer_or_with_its_delivery_where_it_was_pending() => _dispatcher.RunAsync(async () => { @@ -336,6 +452,36 @@ public Task Should_refresh_every_watch_once_where_a_batch_can_t_be_read_answerin await _browser.DeliverAsync("[{\"handle\":", asStream: true); Assert.Equal("""[{"request":"refresh"}]""", (await _browser.NextBatchAsync()).Requests.ToJsonString()); + + // The copy missed what the batch held, so it skips change sets until its snapshot whole arrives. + await _browser.DeliverAsync($$$"""[{"handle":{{{id}}},"generation":0,"changes":[{"op":"replace","path":"/count","value":9}]}]"""); + + Assert.Equal(new Counted(2), watch.Current); + + await _browser.DeliverAsync($$$"""[{"handle":{{{id}}},"generation":0,"snapshot":{"count":4}},{"handle":{{{id}}},"generation":0,"changes":[{"op":"replace","path":"/count","value":5}]}]"""); + + Assert.Equal(new Counted(5), watch.Current); + }); + + [Fact] + public Task Should_answer_a_malformed_delivery_with_null_and_take_the_batches_after_it() => _dispatcher.RunAsync(async () => + { + var watch = _owner.Watch(CountQuery); + var batch = await _browser.NextBatchAsync(); + var id = (long)batch.Requests[0]!["handle"]!; + + batch.Answer("""{"snapshot":{"count":1}}"""); + await watch.ReadyAsync(Token); + + var answers = await _browser.DeliverAsync($$$"""[null,1,{"handle":null},{"handle":"one"},{"handle":{{{id}}},"generation":0,"changes":[{"op":"replace","path":"/count","value":2}]}]"""); + + Assert.Equal("[null,null,null,null,null]", answers.ToJsonString()); + Assert.Equal(new Counted(2), watch.Current); + + await _browser.DeliverAsync($$$"""[{"handle":{{{id}}},"generation":0,"changes":[{"op":"replace","path":"/count","value":3}]}]"""); + + Assert.Equal(new Counted(3), watch.Current); + Assert.False(_browser.HasBatch); }); [Fact] diff --git a/tests/Forma.DOMQL.NET.Tests/FakeBrowser.cs b/tests/Forma.DOMQL.NET.Tests/FakeBrowser.cs index b5d46da..1132db8 100644 --- a/tests/Forma.DOMQL.NET.Tests/FakeBrowser.cs +++ b/tests/Forma.DOMQL.NET.Tests/FakeBrowser.cs @@ -34,11 +34,11 @@ public async Task NextBatchAsync() /// Whether a batch arrived that no test has read. public bool HasBatch => _batches.Reader.TryPeek(out _); - /// Delivers the deliveries given, as one batch of the browser's task, answering what the connection answers. - public async Task DeliverAsync(string deliveries, bool asStream = false) + /// Delivers the deliveries given, as one batch of the browser's task, answering what the connection answers; one sent as a stream opens once completes, where it is given. + public async Task DeliverAsync(string deliveries, bool asStream = false, Task? opened = null) { var receiver = _receiver ?? throw new InvalidOperationException("The connection has not opened"); - var transfer = asStream ? new DomqlTransfer { Stream = new FakeStream(Encoding.UTF8.GetBytes(deliveries)) } : new DomqlTransfer { Deliveries = JsonDocument.Parse(deliveries).RootElement.Clone() }; + var transfer = asStream ? new DomqlTransfer { Stream = new FakeStream(Encoding.UTF8.GetBytes(deliveries), opened) } : new DomqlTransfer { Deliveries = JsonDocument.Parse(deliveries).RootElement.Clone() }; var answers = await receiver.Value.ReceiveAsync(transfer).ConfigureAwait(false); return JsonSerializer.SerializeToNode(answers, JsonSerializerOptions.Web)!.AsArray(); @@ -111,14 +111,21 @@ public async ValueTask InvokeAsync(string identifier, Cancellati } /// A batch that crossed as a stream. - private sealed class FakeStream(byte[] content) : IJSStreamReference + private sealed class FakeStream(byte[] content, Task? opened) : IJSStreamReference { public long Length => content.Length; public bool IsDisposed { get; private set; } public ValueTask OpenReadStreamAsync(long maxAllowedSize = 512000, CancellationToken cancellationToken = default) => - ValueTask.FromResult(new MemoryStream(content)); + opened is null ? ValueTask.FromResult(new MemoryStream(content)) : new ValueTask(OpenLaterAsync()); + + private async Task OpenLaterAsync() + { + await opened!.ConfigureAwait(false); + + return new MemoryStream(content); + } public ValueTask DisposeAsync() { From 404505f8fdbdc778c09ac1b8774f5a20de4b29e1 Mon Sep 17 00:00:00 2001 From: Eyal Alon <3756641+soyeyalon@users.noreply.github.com> Date: Thu, 3 Dec 2026 03:46:14 +0200 Subject: [PATCH 3/7] feat(domql-net): add WaitForAcknowledgment DomqlWatchOptions.WaitForAcknowledgment, true by default, asks DOMQL's connection for a watch whose every change crosses with its browser task where it is false, in order with the events after it, so a handler acting on an event by the watch's state, as a press acts on where the focus went, finds every change before the event. Each change costs a delivery. DOMQL carries it from 1.0.0-preview.5, which the package will depend on once it is released. D3 records it. --- CHANGELOG.md | 1 + docs/decisions.md | 10 ++++++---- docs/design.md | 4 ++-- docs/features-status.md | 4 +++- spec/README.md | 4 +++- src/Forma.DOMQL.NET/DomqlOwner.cs | 15 +++++++++++---- src/Forma.DOMQL.NET/DomqlWatch.cs | 6 ++++++ .../DomqlConnectionTests.cs | 17 +++++++++++++++-- 8 files changed, 47 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b2ee53..a318f1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,5 +12,6 @@ Each release of DOMQL.NET's package, `formaui-net.DOMQL.NET`, newest first, with *Unreleased · DOMQL `1.0.0-preview.4`* - 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. +- 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, as DOMQL `1.0.0-preview.5`'s connection carries 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.4`, which serves that bundle, and on Microsoft.JSInterop. diff --git a/docs/decisions.md b/docs/decisions.md index 1ca4542..cf54c94 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -48,21 +48,23 @@ Each decision taken without stopping to ask, with why and what was declined, for -## D3 — Deliveries are taken in order, none waiting for a handler +## D3 — Deliveries are taken in order, none waiting for a handler, and a watch can wait for no acknowledgment *December 3, 2026* -- **Kind:** Contract, refining how [D1](#d1) takes a batch's deliveries. +- **Kind:** Contract, beside DOMQL's D121, which DOMQL `1.0.0-preview.5` will carry. - **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. - - Taken in the order they crossed, deliveries apply in that order, a streamed batch's among them. + - 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 is answered with its batch's events. + - 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 4c28955..cc85560 100644 --- a/docs/design.md +++ b/docs/design.md @@ -27,8 +27,8 @@ How DOMQL.NET is built to meet [its specification](../spec/README.md). It is DOM ## 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 every delivery applies in the order it crossed, as [D3](decisions.md#d3) records. -- **What a handler still holds.** A batch is answered once its handlers have completed, so a watch whose change shares a batch with a handler awaiting a dialog sends its next change only once the dialog closes. +- **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 a280ff8..e991b66 100644 --- a/docs/features-status.md +++ b/docs/features-status.md @@ -7,7 +7,8 @@ | 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; DOMQL's connection carries it from DOMQL `1.0.0-preview.5`, unreleased | | 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 | @@ -20,4 +21,5 @@ | --- | --- | | The release and promotion workflows, as DOMQL's, and the repository's rules for `main` | The owner's go, as they publish to nuget.org and change the repository's settings | | A test that drives DOMQL.NET through a real browser and a .NET host, as DOMQL's full gate drives its packages | — | +| The package's dependency on DOMQL `1.0.0-preview.5`, whose connection carries a watch that waits for no acknowledgment, CI's DOMQL checkout at its tag, and the links to DOMQL's records at it | DOMQL's release of `1.0.0-preview.5` | | 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 a3e8e70..ea71205 100644 --- a/spec/README.md +++ b/spec/README.md @@ -80,7 +80,8 @@ A **`DomqlWatch`** keeps a copy of its query's result, which each delivery br - **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 the batch this one crossed in is answered, 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.4/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. +- **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.4/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. DOMQL's connection carries it from DOMQL `1.0.0-preview.5`; an earlier one has every watch wait. - **`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. @@ -106,6 +107,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 | diff --git a/src/Forma.DOMQL.NET/DomqlOwner.cs b/src/Forma.DOMQL.NET/DomqlOwner.cs index 7645497..4e51a11 100644 --- a/src/Forma.DOMQL.NET/DomqlOwner.cs +++ b/src/Forma.DOMQL.NET/DomqlOwner.cs @@ -20,9 +20,9 @@ internal DomqlOwner(DomqlConnection connection, string name) internal DomqlConnection Connection { get; } /// - /// Watches a query: its first snapshot arrives with its request's answer, as waits for, and each change after it is applied to the watch's copy, the next one sent - /// only once the browser has heard the batch it crossed in answered. is called with each result once it is applied, one call at a time, with the latest where several arrived - /// meanwhile. + /// Watches a query: its first snapshot arrives with its request's answer, as waits for, and each change after it is applied to the watch's copy, the next one sent, + /// unless is false, only once the browser has heard the batch it crossed in answered. is called with each result once it is + /// applied, one call at a time, with the latest where several arrived meanwhile. /// public DomqlWatch Watch(DomqlQuery query, IReadOnlyDictionary? bindings = null, Func? changed = null, DomqlWatchOptions? options = null) { @@ -119,7 +119,7 @@ private Task StartResult(string kind, DomqlQuery query, IReadOnlyDictio } } -/// How a watch evaluates, as query.watch's options say. +/// How a watch evaluates, as query.watch's options say, and how its changes cross. public sealed record DomqlWatchOptions { /// When it evaluates after a change: frame, the default, at the next animation frame; immediate, at once; or delayed, once has passed without another. @@ -131,6 +131,13 @@ public sealed record DomqlWatchOptions /// Whether it accepts members whose observations miss some changes. public bool AcceptPartialObservation { get; init; } + /// + /// Whether a change waits while the one before it is unacknowledged, joined to those that arise meanwhile, as it does by default. A watch that waits for no acknowledgment crosses each change with the browser + /// task it happened in, in order with the events after it, as a handler that acts on an event by the watch's state needs; each change then costs a delivery. DOMQL's connection carries it from DOMQL + /// 1.0.0-preview.5; an earlier one has every watch wait. + /// + public bool WaitForAcknowledgment { get; init; } = true; + /// Hears each failure of an evaluation, and of a result its type can't hold; the connection's logger hears them where none is given. public Func? Failed { get; init; } } diff --git a/src/Forma.DOMQL.NET/DomqlWatch.cs b/src/Forma.DOMQL.NET/DomqlWatch.cs index 46aadce..8fdd801 100644 --- a/src/Forma.DOMQL.NET/DomqlWatch.cs +++ b/src/Forma.DOMQL.NET/DomqlWatch.cs @@ -49,6 +49,12 @@ internal DomqlWatch(DomqlOwner owner, DomqlQuery query, IReadOnlyDictionary _dispatcher.RunAsync(async () => + { + _ = _owner.Watch(CountQuery, Bindings("focus"), options: new DomqlWatchOptions { Schedule = "immediate", WaitForAcknowledgment = false }); + _ = _owner.Watch(CountQuery, Bindings("panel")); + + var batch = await _browser.NextBatchAsync(); + + Assert.False((bool)batch.Requests[0]!["waitForAcknowledgment"]!); + Assert.Equal("""{"schedule":"immediate"}""", batch.Requests[0]!["options"]!.ToJsonString()); + Assert.Null(batch.Requests[1]!["waitForAcknowledgment"]); + }); + [Fact] public Task Should_take_each_delivery_at_its_place_so_a_handler_finds_the_state_before_its_event_and_none_waits_for_another() => _dispatcher.RunAsync(async () => { var slow = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); var heard = new List(); - var watch = _owner.Watch(CountQuery, Bindings("focus")); + var watch = _owner.Watch(CountQuery, Bindings("focus"), options: new DomqlWatchOptions { WaitForAcknowledgment = false }); DomqlWatch? watched = null; var subscription = _owner.Subscribe(DomqlQuery.Create("panel:presses()"), null, async (string press) => { @@ -247,7 +260,7 @@ public Task Should_take_each_delivery_at_its_place_so_a_handler_finds_the_state_ public Task Should_take_a_batch_after_one_that_crossed_before_it_as_a_stream_still_being_read() => _dispatcher.RunAsync(async () => { var opened = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); - var watch = _owner.Watch(CountQuery); + var watch = _owner.Watch(CountQuery, options: new DomqlWatchOptions { WaitForAcknowledgment = false }); var batch = await _browser.NextBatchAsync(); var id = (long)batch.Requests[0]!["handle"]!; From 082a20c8107faf1c921608ec8aafdcec249d9e50 Mon Sep 17 00:00:00 2001 From: Eyal Alon <3756641+soyeyalon@users.noreply.github.com> Date: Thu, 3 Dec 2026 04:01:46 +0200 Subject: [PATCH 4/7] ci(domql-net): add promotion and release promotion.yml checks every pull request into main as DOMQL's does: it comes from candidate, the full gate passed on its head and kept the package, and its version, which the package project declares, is new and dated in the changelog. release.yml runs on a release tag's push, attaches the package the candidate's gate built to the tag's GitHub release, and publishes it to nuget.org through trusted publishing. Contributing sets out how a release is cut. --- .github/workflows/promotion.yml | 31 +++++++++++++++ .github/workflows/release.yml | 67 +++++++++++++++++++++++++++++++++ CONTRIBUTING.md | 14 +++++++ docs/features-status.md | 1 - 4 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/promotion.yml create mode 100644 .github/workflows/release.yml 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/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/docs/features-status.md b/docs/features-status.md index e991b66..67586a2 100644 --- a/docs/features-status.md +++ b/docs/features-status.md @@ -19,7 +19,6 @@ | Work | Waits for | | --- | --- | -| The release and promotion workflows, as DOMQL's, and the repository's rules for `main` | The owner's go, as they publish to nuget.org and change the repository's settings | | A test that drives DOMQL.NET through a real browser and a .NET host, as DOMQL's full gate drives its packages | — | | The package's dependency on DOMQL `1.0.0-preview.5`, whose connection carries a watch that waits for no acknowledgment, CI's DOMQL checkout at its tag, and the links to DOMQL's records at it | DOMQL's release of `1.0.0-preview.5` | | 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 | From a310233ad13c2b4fe2e7799c6c1b09e0b2eaa369 Mon Sep 17 00:00:00 2001 From: Eyal Alon <3756641+soyeyalon@users.noreply.github.com> Date: Thu, 3 Dec 2026 04:21:08 +0200 Subject: [PATCH 5/7] build(domql-net): depend on DOMQL 1.0.0-preview.5 The package depends on formaui-net.DOMQL 1.0.0-preview.5, whose connection carries a watch that waits for no acknowledgment, and CI checks DOMQL out at its tag. The links to DOMQL's documents move to that release, D3 links DOMQL's D121 there, and the notes that the option needed a later DOMQL go. --- CHANGELOG.md | 6 +++--- CLAUDE.md | 4 ++-- README.md | 2 +- docs/decisions.md | 4 ++-- docs/design.md | 4 ++-- docs/features-status.md | 5 ++--- spec/README.md | 16 ++++++++-------- src/Forma.DOMQL.NET/DomqlOwner.cs | 3 +-- src/Forma.DOMQL.NET/Forma.DOMQL.NET.csproj | 2 +- 9 files changed, 22 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a318f1b..e9e36b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,9 +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`* +*Unreleased · 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. -- 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, as DOMQL `1.0.0-preview.5`'s connection carries it. +- 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.4`, which serves that bundle, and on Microsoft.JSInterop. +- 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/README.md b/README.md index 002c9ba..3fcd60e 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`, runs over the connection DOMQL's release `1.0.0-preview.4` brings, which its package depends on. See [the status](docs/features-status.md). +> **Preview, unreleased.** DOMQL.NET's first preview, `1.0.0-preview.1`, runs over DOMQL's connection, and its package depends on DOMQL's release `1.0.0-preview.5`. See [the status](docs/features-status.md). ```csharp builder.Services.AddDomql(); diff --git a/docs/decisions.md b/docs/decisions.md index cf54c94..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). @@ -52,7 +52,7 @@ Each decision taken without stopping to ask, with why and what was declined, for *December 3, 2026* -- **Kind:** Contract, beside DOMQL's D121, which DOMQL `1.0.0-preview.5` will carry. +- **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. diff --git a/docs/design.md b/docs/design.md index cc85560..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,7 +14,7 @@ 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 diff --git a/docs/features-status.md b/docs/features-status.md index 67586a2..f2cd95c 100644 --- a/docs/features-status.md +++ b/docs/features-status.md @@ -1,6 +1,6 @@ # 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. Its package depends on DOMQL's, `formaui-net.DOMQL`, from that release, and CI runs its gate against a DOMQL checkout at that release's tag. +**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` 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 | | --- | --- | --- | @@ -8,7 +8,7 @@ | 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 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; DOMQL's connection carries it from DOMQL `1.0.0-preview.5`, unreleased | +| 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 | @@ -20,5 +20,4 @@ | Work | Waits for | | --- | --- | | A test that drives DOMQL.NET through a real browser and a .NET host, as DOMQL's full gate drives its packages | — | -| The package's dependency on DOMQL `1.0.0-preview.5`, whose connection carries a watch that waits for no acknowledgment, CI's DOMQL checkout at its tag, and the links to DOMQL's records at it | DOMQL's release of `1.0.0-preview.5` | | 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 ea71205..f194888 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 | | --- | --- | --- | @@ -79,9 +79,9 @@ In this document: A **`DomqlWatch`** keeps a copy of its query's result, which each delivery brings up to date. - **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 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.4/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. DOMQL's connection carries it from DOMQL `1.0.0-preview.5`; an earlier one has every watch wait. +- **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. @@ -94,7 +94,7 @@ A **`DomqlWatch`** keeps a copy of its query's result, which each delivery br - **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.4/spec/behaviors.md#behaviors-answers) set out. +- **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. @@ -123,4 +123,4 @@ A **`DomqlException`** carries a failure's `Code`, its `Kind` and its `Location` - **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, 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/DomqlOwner.cs b/src/Forma.DOMQL.NET/DomqlOwner.cs index 4e51a11..a7d109b 100644 --- a/src/Forma.DOMQL.NET/DomqlOwner.cs +++ b/src/Forma.DOMQL.NET/DomqlOwner.cs @@ -133,8 +133,7 @@ public sealed record DomqlWatchOptions /// /// Whether a change waits while the one before it is unacknowledged, joined to those that arise meanwhile, as it does by default. A watch that waits for no acknowledgment crosses each change with the browser - /// task it happened in, in order with the events after it, as a handler that acts on an event by the watch's state needs; each change then costs a delivery. DOMQL's connection carries it from DOMQL - /// 1.0.0-preview.5; an earlier one has every watch wait. + /// task it happened in, in order with the events after it, as a handler that acts on an event by the watch's state needs; each change then costs a delivery. /// public bool WaitForAcknowledgment { get; init; } = true; diff --git a/src/Forma.DOMQL.NET/Forma.DOMQL.NET.csproj b/src/Forma.DOMQL.NET/Forma.DOMQL.NET.csproj index 0a9f5c2..a53165f 100644 --- a/src/Forma.DOMQL.NET/Forma.DOMQL.NET.csproj +++ b/src/Forma.DOMQL.NET/Forma.DOMQL.NET.csproj @@ -30,7 +30,7 @@ - + From 1d9edd37a36022b3c4e0faaf24e460bbb321ba34 Mon Sep 17 00:00:00 2001 From: Eyal Alon <3756641+soyeyalon@users.noreply.github.com> Date: Thu, 3 Dec 2026 04:26:08 +0200 Subject: [PATCH 6/7] docs(domql-net): say what a watch's query gives The browser keeps a watch's result as live state, so its query gives an object or a list that is never null, and any other is refused with DOMQL3001; the specification said nothing of it, and a test watched a bare count, which a real browser refuses. A smoke test of the packed package in a Blazor Server app found it. --- spec/README.md | 1 + tests/Forma.DOMQL.NET.Tests/DomqlConnectionTests.cs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/README.md b/spec/README.md index f194888..2a3595a 100644 --- a/spec/README.md +++ b/spec/README.md @@ -78,6 +78,7 @@ 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.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. diff --git a/tests/Forma.DOMQL.NET.Tests/DomqlConnectionTests.cs b/tests/Forma.DOMQL.NET.Tests/DomqlConnectionTests.cs index 7f1403e..bd0b51f 100644 --- a/tests/Forma.DOMQL.NET.Tests/DomqlConnectionTests.cs +++ b/tests/Forma.DOMQL.NET.Tests/DomqlConnectionTests.cs @@ -35,7 +35,7 @@ public Task Should_carry_the_requests_of_one_turn_as_one_call_its_query_text_cro { _ = _owner.Watch(CountQuery, Bindings("first")); _ = _owner.Watch(CountQuery, Bindings("second")); - _ = _owner.Watch(DomqlQuery.Create("panel.children.count"), Bindings("third")); + _ = _owner.Watch(DomqlQuery.Create("panel { count = it.children.count }"), Bindings("third")); var batch = await _browser.NextBatchAsync(); @@ -43,7 +43,7 @@ public Task Should_carry_the_requests_of_one_turn_as_one_call_its_query_text_cro Assert.Equal(3, batch.Requests.Count); Assert.Equal("""{"key":1,"text":"{ count = panel.children.count }"}""", batch.Requests[0]!["query"]!.ToJsonString()); Assert.Equal("1", batch.Requests[1]!["query"]!.ToJsonString()); - Assert.Equal("""{"key":2,"text":"panel.children.count"}""", batch.Requests[2]!["query"]!.ToJsonString()); + Assert.Equal("""{"key":2,"text":"panel { count = it.children.count }"}""", batch.Requests[2]!["query"]!.ToJsonString()); Assert.Equal(["watch", "watch", "watch"], batch.Requests.Select(request => (string)request!["request"]!)); Assert.Equal(["panel", "panel", "panel"], batch.Requests.Select(request => (string)request!["owner"]!)); Assert.Equal(["first", "second", "third"], batch.Requests.Select(request => (string)request!["bindings"]!["panel"]!)); From 4a95f20a9dfe8afd7b1ab682375c4ab4768b98ee Mon Sep 17 00:00:00 2001 From: Eyal Alon <3756641+soyeyalon@users.noreply.github.com> Date: Thu, 3 Dec 2026 04:26:45 +0200 Subject: [PATCH 7/7] chore(domql-net): release 1.0.0-preview.1 The first preview, on DOMQL's release 1.0.0-preview.5. It dates the changelog's entry, says how to install the package in the README, whose links are absolute since the package carries it, and is tagged v1.0.0-preview.1, whose release publishes the package to nuget.org. --- CHANGELOG.md | 2 +- README.md | 26 +++++++++++++++++--------- docs/features-status.md | 3 +-- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9e36b0..99a17f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ 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.5`* +*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. - 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. diff --git a/README.md b/README.md index 3fcd60e..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`, runs over DOMQL's connection, and its package depends on DOMQL's release `1.0.0-preview.5`. 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/features-status.md b/docs/features-status.md index f2cd95c..4697279 100644 --- a/docs/features-status.md +++ b/docs/features-status.md @@ -1,6 +1,6 @@ # 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` 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. +**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 | | --- | --- | --- | @@ -20,4 +20,3 @@ | Work | Waits for | | --- | --- | | 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 |