@runic-artifex/react 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +16 -10
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -35,7 +35,7 @@ export function CounterPage({ page }: { page: CounterPageReference }) {
35
35
  const { state, client } = useView(page);
36
36
  const increment = useCommand(() => client?.increment());
37
37
  return <>
38
- <button disabled={!client || increment.pending} onClick={() => void increment.run()}>{state?.count ?? "…"}</button>
38
+ <button disabled={!state?.canIncrement || increment.pending} onClick={() => void increment.run()}>{state?.count ?? "…"}</button>
39
39
  {increment.error !== undefined && <p role="alert">{String(increment.error)}</p>}
40
40
  </>;
41
41
  }
@@ -156,6 +156,12 @@ const navigate = useCommand((name: "showWelcome" | "showCounter") => client?.[na
156
156
  <button onClick={() => void navigate.run("showWelcome")}>Welcome</button>
157
157
  ```
158
158
 
159
+ `pending` covers only this component's run. Whether .NET can run the command is
160
+ the View's state: a command without an argument publishes `can<Name>`, so a
161
+ button combines both, as in `disabled={!state?.canSave || save.pending}`, and is
162
+ disabled before the client connects. A command with an argument has the
163
+ `can<Name>(input)` query on the client instead.
164
+
159
165
  For a command that declares a failure (`[RunicFailure]` in .NET), `run` resolves the
160
166
  `BridgeOutcome`, and `failure` holds the declared failure of the latest run, typed
161
167
  from the outcome, while `error` keeps unexpected failures. Starting a run and
@@ -165,7 +171,7 @@ neither.
165
171
  ## `useOperation(start, options?)`
166
172
 
167
173
  Observes a generated `start<Command>()` operation through the framework-neutral
168
- [operation controller](https://github.com/Runic-Artifex/runic-sdk/tree/v0.11.0/packages/web/views#operation-feedback-and-latest-selection).
174
+ [operation controller](https://github.com/Runic-Artifex/runic-sdk/tree/v0.12.0/packages/web/views#operation-feedback-and-latest-selection).
169
175
  `run(...args)` calls the latest `start`, so it may close over the current client:
170
176
 
171
177
  ```tsx
@@ -194,7 +200,7 @@ controller's options.
194
200
 
195
201
  Admits only the newest of several reads, for example loading the item the user
196
202
  selected last, through the framework-neutral
197
- [latest-operation controller](https://github.com/Runic-Artifex/runic-sdk/tree/v0.11.0/packages/web/views#operation-feedback-and-latest-selection).
203
+ [latest-operation controller](https://github.com/Runic-Artifex/runic-sdk/tree/v0.12.0/packages/web/views#operation-feedback-and-latest-selection).
198
204
  Each `run(intent)` replaces the queued intent and cancels the active read; the next
199
205
  read starts only after the previous one reaches its terminal status and the intent's
200
206
  optional `waitForCompletion` barrier:
@@ -224,7 +230,7 @@ It wraps `onBridgeConnection` from `@runic-artifex/views` (re-exported here sinc
224
230
  `BridgeConnectionState` and `BridgeConnectionOptions` types) and returns
225
231
  `{ state }`, where `state` is a `BridgeConnectionState`: `connecting`,
226
232
  `connected`, `reconnecting` or `lost` (a closed set, see
227
- [Connection state](https://github.com/Runic-Artifex/runic-sdk/tree/v0.11.0/packages/web/views#connection-state)):
233
+ [Connection state](https://github.com/Runic-Artifex/runic-sdk/tree/v0.12.0/packages/web/views#connection-state)):
228
234
 
229
235
  ```tsx
230
236
  import { useBridgeConnection } from "@runic-artifex/react";
@@ -245,7 +251,7 @@ subscribes again; an invalid one throws a `RangeError`. A server render reads
245
251
  Follows the declared menu bar of a Runic Desktop window that leaves it to the
246
252
  page (`DesktopMenuBarPresentation.Page`) while the component is mounted. It
247
253
  wraps `createMenuBarController` from `@runic-artifex/views` (see
248
- [In-page menu bar](https://github.com/Runic-Artifex/runic-sdk/tree/v0.11.0/packages/web/views#in-page-menu-bar)) and returns `{ state, invoke, handleKeyDown }`: `state` is a
254
+ [In-page menu bar](https://github.com/Runic-Artifex/runic-sdk/tree/v0.12.0/packages/web/views#in-page-menu-bar)) and returns `{ state, invoke, handleKeyDown }`: `state` is a
249
255
  `MenuBarState`, and the bar is rendered by the menubar component of the
250
256
  application's own UI library. Runic ships no menubar component.
251
257
 
@@ -275,7 +281,7 @@ The controller starts in an effect, so a server render reads `connecting`, and
275
281
 
276
282
  Base UI's `Menubar` (`@base-ui/react`, the base of shadcn/ui's Base UI
277
283
  Menubar) with a controlled open menu; the
278
- [Notes example](https://github.com/Runic-Artifex/runic-sdk/tree/v0.11.0/examples/notes-view-first#in-page-menu-bar) adds submenus, check and radio
284
+ [Notes example](https://github.com/Runic-Artifex/runic-sdk/tree/v0.12.0/examples/notes-view-first#in-page-menu-bar) adds submenus, check and radio
279
285
  items and is tested with real keys:
280
286
 
281
287
  ```tsx
@@ -340,7 +346,7 @@ const offline = error instanceof BridgeError && error.kind === "disconnected";
340
346
  ```
341
347
 
342
348
  `instanceof` holds for errors from every copy of the package on the page.
343
- [Errors and diagnostics](https://github.com/Runic-Artifex/runic-sdk/tree/v0.11.0/packages/web/views#errors-and-diagnostics)
349
+ [Errors and diagnostics](https://github.com/Runic-Artifex/runic-sdk/tree/v0.12.0/packages/web/views#errors-and-diagnostics)
344
350
  lists the kinds. Any other value, such as an exception that your own connect
345
351
  function or command callback throws, arrives unchanged.
346
352
 
@@ -382,16 +388,16 @@ the application's own dialog.
382
388
  such as a close during the page's first render, is answered by the
383
389
  ViewModel's .NET fallback handler, or fails closed without one.
384
390
 
385
- The [ReactiveUI leave confirmation](https://github.com/Runic-Artifex/runic-sdk/blob/v0.11.0/packages/dotnet/Runic.Application.Views.ReactiveUI/README.md#leave-confirmation-in-a-web-view)
391
+ The [ReactiveUI leave confirmation](https://github.com/Runic-Artifex/runic-sdk/blob/v0.12.0/packages/dotnet/Runic.Application.Views.ReactiveUI/README.md#leave-confirmation-in-a-web-view)
386
392
  has the .NET side and which View answers which departure. In a frontend test,
387
393
  the generated mock's `interactions.<name>.request(input)` resolves with the
388
394
  registered handler's answer; see the
389
- [Testing guide](https://github.com/Runic-Artifex/runic-sdk/tree/v0.11.0/packages/web/views#testing).
395
+ [Testing guide](https://github.com/Runic-Artifex/runic-sdk/tree/v0.12.0/packages/web/views#testing).
390
396
 
391
397
  ## `useCollectionViewport(options)`
392
398
 
393
399
  Follows a fixed-row-height scroll container and returns `{ viewport, ref }`.
394
- `viewport` is the [`collectionViewport`](https://github.com/Runic-Artifex/runic-sdk/tree/v0.11.0/packages/web/views#collectionviewportoptions)
400
+ `viewport` is the [`collectionViewport`](https://github.com/Runic-Artifex/runic-sdk/tree/v0.12.0/packages/web/views#collectionviewportoptions)
395
401
  range for the container; it changes only when the range or sizes change. Send
396
402
  the range to the ViewModel from an effect:
397
403
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runic-artifex/react",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "React hooks for generated Runic Views clients",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -30,13 +30,13 @@
30
30
  },
31
31
  "peerDependencies": {
32
32
  "react": ">=18.3.0 <20",
33
- "@runic-artifex/views": "0.11.0"
33
+ "@runic-artifex/views": "0.12.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@runic-artifex/views": "0.11.0",
36
+ "@runic-artifex/views": "0.12.0",
37
37
  "@types/react": "19.3.0",
38
38
  "@types/react-dom": "19.3.0",
39
- "happy-dom": "20.14.5",
39
+ "happy-dom": "21.0.4",
40
40
  "react": "19.3.0",
41
41
  "react-dom": "19.3.0",
42
42
  "typescript": "6.0.3",
@@ -51,7 +51,7 @@
51
51
  "url": "git+https://github.com/Runic-Artifex/runic-sdk.git",
52
52
  "directory": "packages/web/react"
53
53
  },
54
- "homepage": "https://github.com/Runic-Artifex/runic-sdk/tree/v0.11.0/packages/web/react#readme",
54
+ "homepage": "https://github.com/Runic-Artifex/runic-sdk/tree/v0.12.0/packages/web/react#readme",
55
55
  "bugs": {
56
56
  "url": "https://github.com/Runic-Artifex/runic-sdk/issues"
57
57
  },
@@ -61,5 +61,5 @@
61
61
  "views",
62
62
  "react"
63
63
  ],
64
- "gitHead": "318762a9d5dcdd74303ca30b095fed355a1ab21f"
64
+ "gitHead": "cb95ea2838ba61c7a24b9cda05bf5f0bd6fcc2d7"
65
65
  }