@runic-artifex/react 0.8.0-preview.6 → 0.9.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.
package/README.md CHANGED
@@ -11,7 +11,7 @@ bun add @runic-artifex/react@preview @runic-artifex/views@preview
11
11
  ```
12
12
 
13
13
  Previews are published under the `preview` dist-tag. Install the versions that
14
- match your Runic SDK packages. React 18.3 or later is supported.
14
+ match your Runic SDK packages. React 18.3 and 19 are supported.
15
15
 
16
16
  ```tsx
17
17
  import { useCommand, useView, ViewOutlet, type ViewRegistry } from "@runic-artifex/react";
@@ -41,9 +41,11 @@ export function CounterPage({ page }: { page: CounterPageReference }) {
41
41
  }
42
42
  ```
43
43
 
44
- ## `useView(source)`
44
+ ## `useView(source, options?)`
45
45
 
46
- Returns `{ state, client, error, pending, retry }`:
46
+ Returns `{ state, client, error, pending, retry }`. `options.release(client)`
47
+ replaces `client.dispose()` for a client the hook connected, for example to keep
48
+ a client alive in a cache:
47
49
 
48
50
  - A generated page reference, or `{ connect: connect<Name> }` for a root
49
51
  ViewModel, is connected while the component is mounted and disposed when it
@@ -86,7 +88,12 @@ export function CounterPage({ page }: { page: CounterPageReference }) {
86
88
  The control shows the ViewModel's value, so it reverts when the setter throws
87
89
  or keeps a different value.
88
90
 
89
- ## `useSuspenseView(source)`
91
+ ## `useSuspenseView(source)` (experimental)
92
+
93
+ `useSuspenseView` and `retrySuspenseView` are exported from
94
+ `@runic-artifex/react/experimental`: the module-wide connection cache and its
95
+ ten-second timeout may change in a minor release (see
96
+ [experimental APIs](https://github.com/Runic-Artifex/runic-sdk/blob/v0.9.0/docs/experimental.md#npm-packages)).
90
97
 
91
98
  Suspends the component until a reference connects, then returns
92
99
  `{ state, client }` without `undefined`. A failed connection is thrown to the
@@ -123,8 +130,9 @@ remounts the component; a kind without a component renders an alert, and
123
130
  Returns `{ run, pending, error, failure, reset }`. `run(...args)` calls the latest
124
131
  `command`, so it may close over the current client, and resolves to its result
125
132
  or to `undefined` after a failure, which `error` then holds until the next run.
126
- It never rejects, so handlers need no `try`/`catch`. One command can serve
127
- several buttons:
133
+ It never rejects, so handlers need no `try`/`catch`. Unmounting disposes the
134
+ command's controller, so `pending`, `error` and `failure` stop updating; a run in
135
+ flight still resolves. One command can serve several buttons:
128
136
 
129
137
  ```tsx
130
138
  const navigate = useCommand((name: "showWelcome" | "showCounter") => client?.[name]());
@@ -140,7 +148,7 @@ neither.
140
148
  ## `useOperation(start, options?)`
141
149
 
142
150
  Observes a generated `start<Command>()` operation through the framework-neutral
143
- [operation controller](https://github.com/Runic-Artifex/runic-sdk/tree/v0.8.0-preview.6/packages/web/views#operation-feedback-and-latest-selection).
151
+ [operation controller](https://github.com/Runic-Artifex/runic-sdk/tree/v0.9.0/packages/web/views#operation-feedback-and-latest-selection).
144
152
  `run(...args)` calls the latest `start`, so it may close over the current client:
145
153
 
146
154
  ```tsx
@@ -155,12 +163,39 @@ The result has `pending`, `admitting`, `operation`, `status`, `outcome`, `failur
155
163
  `error`, `cancelled`, `cancellationRequested`, `cancelling`, `cancellation` and
156
164
  `cancelError`, with `run(...args)`, `cancel()` and `reset()`, which never reject. A
157
165
  run that ends with a `cancelled` status sets `cancelled` and resolves to `undefined`
158
- without an `error`; `failed` and `timedOut` statuses are still `error`. `pending`
166
+ without an `error`; `failed` and `timed-out` statuses are still `error`. `pending`
159
167
  stays true after a Cancel response until the operation reaches its terminal status.
160
- Unmounting stops rendering feedback but never cancels accepted work. The optional
168
+ Unmounting disposes the controller, as `useCommand` does: a run still in flight
169
+ resolves to `undefined`, `waitForCompletion` is not called after it, and accepted
170
+ work is never cancelled. StrictMode's simulated unmount, and a component that
171
+ React shows again, start with a fresh controller, so feedback of a run started
172
+ before the unmount ends there. The optional
161
173
  `cancel(operation)` and `waitForCompletion(operation, status)` callbacks are the
162
174
  controller's options.
163
175
 
176
+ ## Errors
177
+
178
+ The `error` of `useView` and of a command or operation handle is typed
179
+ `unknown`: it holds whatever the connection or the call rejected with. A Bridge
180
+ failure is a `BridgeError` from `@runic-artifex/views`; narrow it with
181
+ `instanceof` before reading `kind`, `route` or `detail`:
182
+
183
+ ```ts
184
+ import { BridgeError } from "@runic-artifex/views";
185
+
186
+ const offline = error instanceof BridgeError && error.kind === "disconnected";
187
+ ```
188
+
189
+ `instanceof` holds for errors from every copy of the package on the page.
190
+ [Errors and diagnostics](https://github.com/Runic-Artifex/runic-sdk/tree/v0.9.0/packages/web/views#errors-and-diagnostics)
191
+ lists the kinds. Any other value, such as an exception that your own connect
192
+ function or command callback throws, arrives unchanged.
193
+
194
+ The hooks run in the browser or webview that a Runic host serves. `useView`
195
+ connects in an effect, but `useSuspenseView` connects during render, so a server
196
+ render would try to connect: render the components that use them on the client
197
+ only.
198
+
164
199
  ## Interactions
165
200
 
166
201
  A ReactiveUI `Interaction<TInput, TOutput>` on the ViewModel, such as the
@@ -194,16 +229,19 @@ the application's own dialog.
194
229
  such as a close during the page's first render, is answered by the
195
230
  ViewModel's .NET fallback handler, or fails closed without one.
196
231
 
197
- The [ReactiveUI leave confirmation](https://github.com/Runic-Artifex/runic-sdk/blob/v0.8.0-preview.6/packages/dotnet/Runic.Application.Views.ReactiveUI/README.md#leave-confirmation-in-a-web-view)
232
+ The [ReactiveUI leave confirmation](https://github.com/Runic-Artifex/runic-sdk/blob/v0.9.0/packages/dotnet/Runic.Application.Views.ReactiveUI/README.md#leave-confirmation-in-a-web-view)
198
233
  has the .NET side and which View answers which departure. In a frontend test,
199
234
  the generated mock's `interactions.<name>.request(input)` resolves with the
200
235
  registered handler's answer; see the
201
- [Testing guide](https://github.com/Runic-Artifex/runic-sdk/tree/v0.8.0-preview.6/packages/web/views#testing).
236
+ [Testing guide](https://github.com/Runic-Artifex/runic-sdk/tree/v0.9.0/packages/web/views#testing).
237
+
238
+ ## `useCollectionViewport(options)` (experimental)
202
239
 
203
- ## `useCollectionViewport(options)`
240
+ Exported from `@runic-artifex/react/experimental`, like the
241
+ `@runic-artifex/views/experimental` controller it wraps.
204
242
 
205
243
  Follows a fixed-row-height scroll container and returns `{ viewport, ref }`.
206
- `viewport` is the [`collectionViewport`](https://github.com/Runic-Artifex/runic-sdk/tree/v0.8.0-preview.6/packages/web/views#collectionviewportoptions)
244
+ `viewport` is the [`collectionViewport`](https://github.com/Runic-Artifex/runic-sdk/tree/v0.9.0/packages/web/views#collectionviewportoptions-experimental)
207
245
  range for the container; it changes only when the range or sizes change. Send
208
246
  the range to the ViewModel from an effect:
209
247
 
@@ -0,0 +1,2 @@
1
+ export { retrySuspenseView, useSuspenseView, type SuspenseViewHandle } from "./suspense.js";
2
+ export { useCollectionViewport, type CollectionViewportHandle } from "./viewport.js";
@@ -0,0 +1,4 @@
1
+ // `@runic-artifex/react/experimental`: hooks whose shape may still change in a minor release
2
+ // (docs/experimental.md). Graduation moves an export to `@runic-artifex/react`.
3
+ export { retrySuspenseView, useSuspenseView } from "./suspense.js";
4
+ export { useCollectionViewport } from "./viewport.js";
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { type ComponentType, type ReactNode } from "react";
2
- import { type BridgeOperation, type BridgeOutcomeFailure, type OperationController, type OperationControllerOptions, type OperationState, type CollectionViewport, type CollectionViewportOptions, type ViewClient, type ViewConnector, type ViewReference, type ViewSource } from "@runic-artifex/views";
3
- export type { CollectionViewport, CollectionViewportOptions, ViewClient, ViewConnector, ViewReference, ViewSource } from "@runic-artifex/views";
2
+ import { type BridgeOperation, type BridgeOutcomeFailure, type OperationController, type OperationControllerOptions, type OperationState, type PageReference, type ViewClient, type ViewSource } from "@runic-artifex/views";
4
3
  export interface ViewHandle<TClient extends ViewClient> {
5
4
  /** The latest state, or undefined until the client connects. */
6
5
  readonly state: TClient["snapshot"] | undefined;
@@ -13,6 +12,10 @@ export interface ViewHandle<TClient extends ViewClient> {
13
12
  /** Connects a reference again after a failure. */
14
13
  retry(): void;
15
14
  }
15
+ export interface UseViewOptions<TClient extends ViewClient> {
16
+ /** Releases a client this hook connected. Defaults to `client.dispose()`. */
17
+ readonly release?: (client: TClient) => void;
18
+ }
16
19
  /**
17
20
  * Connects a generated View reference for the lifetime of the component and
18
21
  * renders its state through `useSyncExternalStore`. A changed reference
@@ -23,44 +26,19 @@ export interface ViewHandle<TClient extends ViewClient> {
23
26
  * `{ connect: connectWorkspace }` does not reconnect. In development a
24
27
  * `connect` function recreated on every render logs a warning.
25
28
  */
26
- export declare function useView<TClient extends ViewClient>(source: ViewSource<TClient>): ViewHandle<TClient>;
27
- /**
28
- * Forgets a failed `useSuspenseView` connection, so the next render connects
29
- * again. Call it from an error boundary's reset before rendering the
30
- * component again. A connection that is pending or connected is unaffected.
31
- */
32
- export declare function retrySuspenseView(source: ViewConnector<ViewClient>): void;
33
- export interface SuspenseViewHandle<TClient extends ViewClient> {
34
- /** The latest state. */
35
- readonly state: TClient["snapshot"];
36
- /** The connected client. */
37
- readonly client: TClient;
38
- }
39
- /**
40
- * Suspends the component until a generated View reference connects, then
41
- * renders its state. A failed connection is thrown to the nearest error
42
- * boundary; call `retrySuspenseView(reference)` when resetting the boundary to
43
- * connect again. An unretried failure is forgotten after ten seconds.
44
- *
45
- * Components that pass a reference with the same `connect` function share one
46
- * client, which is disposed after the last of them unmounts. Pass a stable
47
- * function such as a generated page reference or `{ connect: connectWorkspace }`:
48
- * a function recreated on every render never resolves. An already connected
49
- * client is observed and left to its owner.
50
- */
51
- export declare function useSuspenseView<TClient extends ViewClient>(source: ViewConnector<TClient> | TClient): SuspenseViewHandle<TClient>;
29
+ export declare function useView<TClient extends ViewClient>(source: ViewSource<TClient>, options?: UseViewOptions<TClient>): ViewHandle<TClient>;
52
30
  /**
53
31
  * A build-known map checks each generated reference kind against its component's `page` prop. A nullable
54
32
  * reference, such as a region slot's `State["main"]`, checks its non-null kinds.
55
33
  */
56
- export type ViewRegistry<R extends ViewReference | null | undefined> = {
34
+ export type ViewRegistry<R extends PageReference | null | undefined> = {
57
35
  readonly [K in NonNullable<R>["kind"]]: ComponentType<{
58
36
  readonly page: Extract<NonNullable<R>, {
59
37
  readonly kind: K;
60
38
  }>;
61
39
  }>;
62
40
  };
63
- export interface ViewOutletProps<R extends ViewReference> {
41
+ export interface ViewOutletProps<R extends PageReference> {
64
42
  /** The presented reference, such as `state.main`. */
65
43
  readonly content: R | null | undefined;
66
44
  readonly registry: ViewRegistry<R>;
@@ -72,7 +50,7 @@ export interface ViewOutletProps<R extends ViewReference> {
72
50
  * the reference as its `page` prop. A different reference remounts the
73
51
  * component. A kind without a component renders an alert.
74
52
  */
75
- export declare function ViewOutlet<R extends ViewReference>({ content, registry, fallback }: ViewOutletProps<R>): ReactNode;
53
+ export declare function ViewOutlet<R extends PageReference>({ content, registry, fallback }: ViewOutletProps<R>): ReactNode;
76
54
  export interface CommandHandle<TArgs extends readonly unknown[], TResult, TFailure = BridgeOutcomeFailure<TResult>> {
77
55
  /**
78
56
  * Runs the command. Resolves to its result, including a `BridgeOutcome` with a
@@ -94,7 +72,9 @@ export interface CommandHandle<TArgs extends readonly unknown[], TResult, TFailu
94
72
  }
95
73
  /**
96
74
  * Tracks a command's pending state and failure for rendering. `run` always
97
- * calls the latest `command`, so it may close over the current client:
75
+ * calls the latest `command`, so it may close over the current client. Unmounting
76
+ * disposes the controller: `pending`, `error` and `failure` stop updating, while a
77
+ * run still in flight resolves as usual.
98
78
  *
99
79
  * ```tsx
100
80
  * const increment = useCommand(() => client?.increment());
@@ -108,8 +88,9 @@ export interface OperationHandle<TArgs extends readonly unknown[], TResult, TFai
108
88
  * Tracks Start admission, pending work, cancellation and terminal feedback of a
109
89
  * generated `start<Command>()` operation for rendering. `run` always calls the
110
90
  * latest `start` and options, so they may close over the current client. A run
111
- * that ends `cancelled` sets `cancelled`, not `error`. Unmounting stops rendering
112
- * feedback; it never cancels accepted work.
91
+ * that ends `cancelled` sets `cancelled`, not `error`. Unmounting disposes the
92
+ * controller: a run still in flight resolves to undefined and `waitForCompletion`
93
+ * is not called after it, but accepted work is never cancelled.
113
94
  *
114
95
  * ```tsx
115
96
  * const push = useOperation((remote: string) => client?.startPush(remote));
@@ -119,16 +100,3 @@ export interface OperationHandle<TArgs extends readonly unknown[], TResult, TFai
119
100
  * ```
120
101
  */
121
102
  export declare function useOperation<TArgs extends readonly unknown[], TResult, TFailure = never>(start: (...args: TArgs) => BridgeOperation<TResult, TFailure> | undefined | PromiseLike<BridgeOperation<TResult, TFailure> | undefined>, options?: OperationControllerOptions<TResult, TFailure>): OperationHandle<TArgs, TResult, TFailure>;
122
- export interface CollectionViewportHandle {
123
- /** The rows to request and the sizes to render. */
124
- readonly viewport: CollectionViewport;
125
- /** Attach to the scroll container: `<div ref={ref}>`. */
126
- readonly ref: (element: HTMLElement | null) => void;
127
- }
128
- /**
129
- * Follows a fixed-row-height scroll container and returns the rows to request
130
- * from .NET. Send `viewport.start` and `viewport.size` to the ViewModel from an
131
- * effect; the hook only measures.
132
- */
133
- export declare function useCollectionViewport(options: CollectionViewportOptions): CollectionViewportHandle;
134
- //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { createElement, useCallback, useEffect, useInsertionEffect, useReducer, useRef, useState, useSyncExternalStore, } from "react";
2
- import { createCollectionViewportController, createCommandController, createOperationController, createViewController, isViewClient, viewSourceIdentity, } from "@runic-artifex/views";
2
+ import { createCommandController, createOperationController, createViewController, } from "@runic-artifex/views";
3
+ import { isViewClient, viewSourceIdentity } from "@runic-artifex/views/bindings";
3
4
  // An inline `{ connect: () => connectX() }` creates a new function on every
4
5
  // render, so every render reconnects and each connection renders again.
5
6
  function warnInlineConnect(tracker, connect) {
@@ -62,8 +63,15 @@ function createViewStore(controller) {
62
63
  * `{ connect: connectWorkspace }` does not reconnect. In development a
63
64
  * `connect` function recreated on every render logs a warning.
64
65
  */
65
- export function useView(source) {
66
- const [controller] = useState(() => createViewController());
66
+ export function useView(source, options = {}) {
67
+ const release = useRef(options.release);
68
+ useInsertionEffect(() => { release.current = options.release; });
69
+ const [controller] = useState(() => createViewController({
70
+ release: client => { if (release.current)
71
+ release.current(client);
72
+ else
73
+ client.dispose(); },
74
+ }));
67
75
  const [store] = useState(() => createViewStore(controller));
68
76
  const tracker = useRef({ connect: undefined, text: "", times: [], warned: false });
69
77
  const identity = viewSourceIdentity(source);
@@ -87,95 +95,6 @@ export function useView(source) {
87
95
  return { state: undefined, client: undefined, error: undefined, pending: source !== null && source !== undefined, retry };
88
96
  return { state: current.state, client: current.client, error: current.error, pending: current.pending, retry };
89
97
  }
90
- // Suspense discards the state of a component that never mounted, so pending
91
- // connections live here, keyed by connect function, until a component claims them.
92
- const suspended = new WeakMap();
93
- const unclaimedConnectionTimeout = 10_000;
94
- function releaseLater(key, entry, delay) {
95
- clearTimeout(entry.timer);
96
- entry.timer = setTimeout(() => {
97
- if (entry.users !== 0 || suspended.get(key) !== entry)
98
- return;
99
- suspended.delete(key);
100
- entry.client?.dispose();
101
- }, delay);
102
- }
103
- function suspendedConnection(connector) {
104
- const key = connector.connect;
105
- const existing = suspended.get(key);
106
- if (existing)
107
- return existing;
108
- const entry = { status: "pending", promise: Promise.resolve(), users: 0 };
109
- entry.promise = Promise.resolve().then(() => connector.connect()).then(client => {
110
- entry.status = "ready";
111
- entry.client = client;
112
- // Release a connection whose render was abandoned before it mounted.
113
- releaseLater(key, entry, unclaimedConnectionTimeout);
114
- }, (error) => {
115
- entry.status = "failed";
116
- entry.error = error;
117
- // Keep the failure for the error boundary; forget it later so a later render reconnects.
118
- entry.timer = setTimeout(() => { if (suspended.get(key) === entry)
119
- suspended.delete(key); }, unclaimedConnectionTimeout);
120
- });
121
- suspended.set(key, entry);
122
- return entry;
123
- }
124
- /**
125
- * Forgets a failed `useSuspenseView` connection, so the next render connects
126
- * again. Call it from an error boundary's reset before rendering the
127
- * component again. A connection that is pending or connected is unaffected.
128
- */
129
- export function retrySuspenseView(source) {
130
- const entry = suspended.get(source.connect);
131
- if (entry?.status !== "failed")
132
- return;
133
- clearTimeout(entry.timer);
134
- suspended.delete(source.connect);
135
- }
136
- /**
137
- * Suspends the component until a generated View reference connects, then
138
- * renders its state. A failed connection is thrown to the nearest error
139
- * boundary; call `retrySuspenseView(reference)` when resetting the boundary to
140
- * connect again. An unretried failure is forgotten after ten seconds.
141
- *
142
- * Components that pass a reference with the same `connect` function share one
143
- * client, which is disposed after the last of them unmounts. Pass a stable
144
- * function such as a generated page reference or `{ connect: connectWorkspace }`:
145
- * a function recreated on every render never resolves. An already connected
146
- * client is observed and left to its owner.
147
- */
148
- export function useSuspenseView(source) {
149
- const connector = isViewClient(source) ? undefined : source;
150
- const entry = connector ? suspendedConnection(connector) : undefined;
151
- const [, refresh] = useReducer((count) => count + 1, 0);
152
- useEffect(() => {
153
- if (!connector || !entry)
154
- return;
155
- const key = connector.connect;
156
- // The connection was released before this component committed: connect again.
157
- if (suspended.get(key) !== entry) {
158
- refresh();
159
- return;
160
- }
161
- entry.users++;
162
- clearTimeout(entry.timer);
163
- return () => {
164
- entry.users--;
165
- if (entry.users === 0)
166
- releaseLater(key, entry, 0);
167
- };
168
- }, [entry]);
169
- if (entry?.status === "pending")
170
- throw entry.promise;
171
- if (entry?.status === "failed")
172
- throw entry.error;
173
- const client = (entry ? entry.client : source);
174
- const subscribe = useCallback((onChange) => client.subscribe(() => onChange()), [client]);
175
- const read = useCallback(() => client.snapshot, [client]);
176
- const state = useSyncExternalStore(subscribe, read, read);
177
- return { state, client };
178
- }
179
98
  const referenceKeys = new WeakMap();
180
99
  let nextReferenceKey = 0;
181
100
  function referenceKey(reference) {
@@ -197,9 +116,35 @@ export function ViewOutlet({ content, registry, fallback = null }) {
197
116
  return createElement("p", { role: "alert" }, `No web component is registered for ${content.kind}.`);
198
117
  return createElement(component, { key: referenceKey(content), page: content });
199
118
  }
119
+ // A command or operation controller lives while its component is mounted: unmounting disposes it,
120
+ // which stops its feedback and, for an operation, settles its pending run promises and stops
121
+ // observing accepted work (it never cancels the work). StrictMode's simulated unmount, and a component that React shows again (`<Activity>`),
122
+ // mount once more with a fresh controller, so feedback of runs started before the unmount ends.
123
+ const disposedControllers = new WeakSet();
124
+ function useMountedController(create) {
125
+ const controller = useRef(null);
126
+ if (controller.current === null)
127
+ controller.current = create();
128
+ const [, remount] = useReducer((count) => count + 1, 0);
129
+ useEffect(() => {
130
+ if (disposedControllers.has(controller.current)) {
131
+ controller.current = create();
132
+ remount();
133
+ }
134
+ const mounted = controller.current;
135
+ return () => {
136
+ disposedControllers.add(mounted);
137
+ mounted.dispose();
138
+ };
139
+ // The controller reads the latest callbacks through refs, so it is created once per mount.
140
+ }, []);
141
+ return controller.current;
142
+ }
200
143
  /**
201
144
  * Tracks a command's pending state and failure for rendering. `run` always
202
- * calls the latest `command`, so it may close over the current client:
145
+ * calls the latest `command`, so it may close over the current client. Unmounting
146
+ * disposes the controller: `pending`, `error` and `failure` stop updating, while a
147
+ * run still in flight resolves as usual.
203
148
  *
204
149
  * ```tsx
205
150
  * const increment = useCommand(() => client?.increment());
@@ -209,7 +154,7 @@ export function ViewOutlet({ content, registry, fallback = null }) {
209
154
  export function useCommand(command) {
210
155
  const latest = useRef(command);
211
156
  useInsertionEffect(() => { latest.current = command; });
212
- const [controller] = useState(() => createCommandController((...args) => latest.current(...args)));
157
+ const controller = useMountedController(() => createCommandController((...args) => latest.current(...args)));
213
158
  const read = useCallback(() => controller.current, [controller]);
214
159
  const { pending, error, failure } = useSyncExternalStore(controller.subscribe, read, read);
215
160
  return { run: controller.run, pending, error, failure, reset: controller.reset };
@@ -218,8 +163,9 @@ export function useCommand(command) {
218
163
  * Tracks Start admission, pending work, cancellation and terminal feedback of a
219
164
  * generated `start<Command>()` operation for rendering. `run` always calls the
220
165
  * latest `start` and options, so they may close over the current client. A run
221
- * that ends `cancelled` sets `cancelled`, not `error`. Unmounting stops rendering
222
- * feedback; it never cancels accepted work.
166
+ * that ends `cancelled` sets `cancelled`, not `error`. Unmounting disposes the
167
+ * controller: a run still in flight resolves to undefined and `waitForCompletion`
168
+ * is not called after it, but accepted work is never cancelled.
223
169
  *
224
170
  * ```tsx
225
171
  * const push = useOperation((remote: string) => client?.startPush(remote));
@@ -231,7 +177,7 @@ export function useCommand(command) {
231
177
  export function useOperation(start, options = {}) {
232
178
  const latest = useRef({ start, options });
233
179
  useInsertionEffect(() => { latest.current = { start, options }; });
234
- const [controller] = useState(() => createOperationController((...args) => latest.current.start(...args), {
180
+ const controller = useMountedController(() => createOperationController((...args) => latest.current.start(...args), {
235
181
  cancel: operation => latest.current.options.cancel ? latest.current.options.cancel(operation) : operation.cancel(),
236
182
  waitForCompletion: (operation, status) => latest.current.options.waitForCompletion?.(operation, status),
237
183
  }));
@@ -239,20 +185,3 @@ export function useOperation(start, options = {}) {
239
185
  const current = useSyncExternalStore(controller.subscribe, read, read);
240
186
  return { ...current, run: controller.run, cancel: controller.cancel, reset: controller.reset };
241
187
  }
242
- /**
243
- * Follows a fixed-row-height scroll container and returns the rows to request
244
- * from .NET. Send `viewport.start` and `viewport.size` to the ViewModel from an
245
- * effect; the hook only measures.
246
- */
247
- export function useCollectionViewport(options) {
248
- const [controller] = useState(() => createCollectionViewportController(options));
249
- const { totalCount, rowHeight, overscan } = options;
250
- useEffect(() => {
251
- controller.update({ totalCount, rowHeight, ...(overscan === undefined ? {} : { overscan }) });
252
- }, [controller, totalCount, rowHeight, overscan]);
253
- const read = useCallback(() => controller.current, [controller]);
254
- const viewport = useSyncExternalStore(controller.subscribe, read, read);
255
- const ref = useCallback((element) => controller.attach(element), [controller]);
256
- return { viewport, ref };
257
- }
258
- //# sourceMappingURL=index.js.map
@@ -0,0 +1,26 @@
1
+ import type { ViewClient, ViewConnector } from "@runic-artifex/views";
2
+ /**
3
+ * Forgets a failed `useSuspenseView` connection, so the next render connects
4
+ * again. Call it from an error boundary's reset before rendering the
5
+ * component again. A connection that is pending or connected is unaffected.
6
+ */
7
+ export declare function retrySuspenseView(source: ViewConnector<ViewClient>): void;
8
+ export interface SuspenseViewHandle<TClient extends ViewClient> {
9
+ /** The latest state. */
10
+ readonly state: TClient["snapshot"];
11
+ /** The connected client. */
12
+ readonly client: TClient;
13
+ }
14
+ /**
15
+ * Suspends the component until a generated View reference connects, then
16
+ * renders its state. A failed connection is thrown to the nearest error
17
+ * boundary; call `retrySuspenseView(reference)` when resetting the boundary to
18
+ * connect again. An unretried failure is forgotten after ten seconds.
19
+ *
20
+ * Components that pass a reference with the same `connect` function share one
21
+ * client, which is disposed after the last of them unmounts. Pass a stable
22
+ * function such as a generated page reference or `{ connect: connectWorkspace }`:
23
+ * a function recreated on every render never resolves. An already connected
24
+ * client is observed and left to its owner.
25
+ */
26
+ export declare function useSuspenseView<TClient extends ViewClient>(source: ViewConnector<TClient> | TClient): SuspenseViewHandle<TClient>;
@@ -0,0 +1,91 @@
1
+ import { useCallback, useEffect, useReducer, useSyncExternalStore } from "react";
2
+ import { isViewClient } from "@runic-artifex/views/bindings";
3
+ // Suspense discards the state of a component that never mounted, so pending
4
+ // connections live here, keyed by connect function, until a component claims them.
5
+ const suspended = new WeakMap();
6
+ const unclaimedConnectionTimeout = 10_000;
7
+ function releaseLater(key, entry, delay) {
8
+ clearTimeout(entry.timer);
9
+ entry.timer = setTimeout(() => {
10
+ if (entry.users !== 0 || suspended.get(key) !== entry)
11
+ return;
12
+ suspended.delete(key);
13
+ entry.client?.dispose();
14
+ }, delay);
15
+ }
16
+ function suspendedConnection(connector) {
17
+ const key = connector.connect;
18
+ const existing = suspended.get(key);
19
+ if (existing)
20
+ return existing;
21
+ const entry = { status: "pending", promise: Promise.resolve(), users: 0 };
22
+ entry.promise = Promise.resolve().then(() => connector.connect()).then(client => {
23
+ entry.status = "ready";
24
+ entry.client = client;
25
+ // Release a connection whose render was abandoned before it mounted.
26
+ releaseLater(key, entry, unclaimedConnectionTimeout);
27
+ }, (error) => {
28
+ entry.status = "failed";
29
+ entry.error = error;
30
+ // Keep the failure for the error boundary; forget it later so a later render reconnects.
31
+ entry.timer = setTimeout(() => { if (suspended.get(key) === entry)
32
+ suspended.delete(key); }, unclaimedConnectionTimeout);
33
+ });
34
+ suspended.set(key, entry);
35
+ return entry;
36
+ }
37
+ /**
38
+ * Forgets a failed `useSuspenseView` connection, so the next render connects
39
+ * again. Call it from an error boundary's reset before rendering the
40
+ * component again. A connection that is pending or connected is unaffected.
41
+ */
42
+ export function retrySuspenseView(source) {
43
+ const entry = suspended.get(source.connect);
44
+ if (entry?.status !== "failed")
45
+ return;
46
+ clearTimeout(entry.timer);
47
+ suspended.delete(source.connect);
48
+ }
49
+ /**
50
+ * Suspends the component until a generated View reference connects, then
51
+ * renders its state. A failed connection is thrown to the nearest error
52
+ * boundary; call `retrySuspenseView(reference)` when resetting the boundary to
53
+ * connect again. An unretried failure is forgotten after ten seconds.
54
+ *
55
+ * Components that pass a reference with the same `connect` function share one
56
+ * client, which is disposed after the last of them unmounts. Pass a stable
57
+ * function such as a generated page reference or `{ connect: connectWorkspace }`:
58
+ * a function recreated on every render never resolves. An already connected
59
+ * client is observed and left to its owner.
60
+ */
61
+ export function useSuspenseView(source) {
62
+ const connector = isViewClient(source) ? undefined : source;
63
+ const entry = connector ? suspendedConnection(connector) : undefined;
64
+ const [, refresh] = useReducer((count) => count + 1, 0);
65
+ useEffect(() => {
66
+ if (!connector || !entry)
67
+ return;
68
+ const key = connector.connect;
69
+ // The connection was released before this component committed: connect again.
70
+ if (suspended.get(key) !== entry) {
71
+ refresh();
72
+ return;
73
+ }
74
+ entry.users++;
75
+ clearTimeout(entry.timer);
76
+ return () => {
77
+ entry.users--;
78
+ if (entry.users === 0)
79
+ releaseLater(key, entry, 0);
80
+ };
81
+ }, [entry]);
82
+ if (entry?.status === "pending")
83
+ throw entry.promise;
84
+ if (entry?.status === "failed")
85
+ throw entry.error;
86
+ const client = (entry ? entry.client : source);
87
+ const subscribe = useCallback((onChange) => client.subscribe(() => onChange()), [client]);
88
+ const read = useCallback(() => client.snapshot, [client]);
89
+ const state = useSyncExternalStore(subscribe, read, read);
90
+ return { state, client };
91
+ }
@@ -0,0 +1,13 @@
1
+ import { type CollectionViewport, type CollectionViewportOptions } from "@runic-artifex/views/experimental";
2
+ export interface CollectionViewportHandle {
3
+ /** The rows to request and the sizes to render. */
4
+ readonly viewport: CollectionViewport;
5
+ /** Attach to the scroll container: `<div ref={ref}>`. */
6
+ readonly ref: (element: HTMLElement | null) => void;
7
+ }
8
+ /**
9
+ * Follows a fixed-row-height scroll container and returns the rows to request
10
+ * from .NET. Send `viewport.start` and `viewport.size` to the ViewModel from an
11
+ * effect; the hook only measures.
12
+ */
13
+ export declare function useCollectionViewport(options: CollectionViewportOptions): CollectionViewportHandle;
@@ -0,0 +1,18 @@
1
+ import { useCallback, useEffect, useState, useSyncExternalStore } from "react";
2
+ import { createCollectionViewportController, } from "@runic-artifex/views/experimental";
3
+ /**
4
+ * Follows a fixed-row-height scroll container and returns the rows to request
5
+ * from .NET. Send `viewport.start` and `viewport.size` to the ViewModel from an
6
+ * effect; the hook only measures.
7
+ */
8
+ export function useCollectionViewport(options) {
9
+ const [controller] = useState(() => createCollectionViewportController(options));
10
+ const { totalCount, rowHeight, overscan } = options;
11
+ useEffect(() => {
12
+ controller.update({ totalCount, rowHeight, ...(overscan === undefined ? {} : { overscan }) });
13
+ }, [controller, totalCount, rowHeight, overscan]);
14
+ const read = useCallback(() => controller.current, [controller]);
15
+ const viewport = useSyncExternalStore(controller.subscribe, read, read);
16
+ const ref = useCallback((element) => controller.attach(element), [controller]);
17
+ return { viewport, ref };
18
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runic-artifex/react",
3
- "version": "0.8.0-preview.6",
3
+ "version": "0.9.0",
4
4
  "description": "React hooks for generated Runic Views clients",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -16,7 +16,13 @@
16
16
  "exports": {
17
17
  ".": {
18
18
  "types": "./dist/index.d.ts",
19
- "import": "./dist/index.js"
19
+ "import": "./dist/index.js",
20
+ "default": "./dist/index.js"
21
+ },
22
+ "./experimental": {
23
+ "types": "./dist/experimental.d.ts",
24
+ "import": "./dist/experimental.js",
25
+ "default": "./dist/experimental.js"
20
26
  },
21
27
  "./package.json": "./package.json"
22
28
  },
@@ -29,10 +35,10 @@
29
35
  },
30
36
  "peerDependencies": {
31
37
  "react": ">=18.3.0 <20",
32
- "@runic-artifex/views": "0.8.0-preview.6"
38
+ "@runic-artifex/views": "0.9.0"
33
39
  },
34
40
  "devDependencies": {
35
- "@runic-artifex/views": "0.8.0-preview.6",
41
+ "@runic-artifex/views": "0.9.0",
36
42
  "@types/react": "19.3.0",
37
43
  "@types/react-dom": "19.3.0",
38
44
  "happy-dom": "20.14.5",
@@ -41,9 +47,6 @@
41
47
  "typescript": "6.0.3",
42
48
  "vitest": "5.0.3"
43
49
  },
44
- "engines": {
45
- "node": ">=24.18.0 <25"
46
- },
47
50
  "publishConfig": {
48
51
  "access": "public",
49
52
  "tag": "preview"
@@ -53,7 +56,7 @@
53
56
  "url": "git+https://github.com/Runic-Artifex/runic-sdk.git",
54
57
  "directory": "packages/web/react"
55
58
  },
56
- "homepage": "https://github.com/Runic-Artifex/runic-sdk/tree/v0.8.0-preview.6/packages/web/react#readme",
59
+ "homepage": "https://github.com/Runic-Artifex/runic-sdk/tree/v0.9.0/packages/web/react#readme",
57
60
  "bugs": {
58
61
  "url": "https://github.com/Runic-Artifex/runic-sdk/issues"
59
62
  },
@@ -63,5 +66,5 @@
63
66
  "views",
64
67
  "react"
65
68
  ],
66
- "gitHead": "9840f55faf97e0258af065eaa75c380802bc69ff"
69
+ "gitHead": "6793f99c726af8b1d05067108761905aa5e8d0d6"
67
70
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,aAAa,EAClB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,EAOL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,cAAc,EACnB,KAA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