@runic-artifex/react 0.6.0-preview.1 → 0.7.0-preview.1
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 +98 -9
- package/dist/index.d.ts +94 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +217 -34
- package/dist/index.js.map +1 -1
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# `@runic-artifex/react`
|
|
2
2
|
|
|
3
|
-
React
|
|
4
|
-
`@runic-artifex/views`,
|
|
3
|
+
React hooks and outlet for clients generated by Runic Views. The generated
|
|
4
|
+
modules import `@runic-artifex/views`, which this package also builds on, so
|
|
5
|
+
install both:
|
|
5
6
|
|
|
6
7
|
```sh
|
|
7
8
|
npm install @runic-artifex/react@preview @runic-artifex/views@preview
|
|
@@ -13,26 +14,36 @@ Previews are published under the `preview` dist-tag. Install the versions that
|
|
|
13
14
|
match your Runic SDK packages. React 18.3 or later is supported.
|
|
14
15
|
|
|
15
16
|
```tsx
|
|
16
|
-
import { useView } from "@runic-artifex/react";
|
|
17
|
-
import { connectWorkspace } from "./generated/workspace.js";
|
|
17
|
+
import { useCommand, useView, ViewOutlet, type ViewRegistry } from "@runic-artifex/react";
|
|
18
|
+
import { connectWorkspace, type WorkspaceState } from "./generated/workspace.js";
|
|
18
19
|
import type { CounterPageReference } from "./generated/counter.js";
|
|
19
20
|
|
|
20
21
|
const workspace = { connect: connectWorkspace };
|
|
22
|
+
const pages = { counter: CounterPage } satisfies ViewRegistry<WorkspaceState["main"]>;
|
|
21
23
|
|
|
22
24
|
export function App() {
|
|
23
25
|
const { state, client, error } = useView(workspace);
|
|
26
|
+
const showCounter = useCommand(() => client?.showCounter());
|
|
24
27
|
if (error) return <p role="alert">{String(error)}</p>;
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
return <>
|
|
29
|
+
<button disabled={!client} onClick={() => void showCounter.run()}>Counter</button>
|
|
30
|
+
<ViewOutlet content={state?.main} registry={pages} fallback={<p>Connecting…</p>} />
|
|
31
|
+
</>;
|
|
27
32
|
}
|
|
28
33
|
|
|
29
34
|
export function CounterPage({ page }: { page: CounterPageReference }) {
|
|
30
35
|
const { state, client } = useView(page);
|
|
31
|
-
|
|
36
|
+
const increment = useCommand(() => client?.increment());
|
|
37
|
+
return <>
|
|
38
|
+
<button disabled={!client || increment.pending} onClick={() => void increment.run()}>{state?.count ?? "…"}</button>
|
|
39
|
+
{increment.error !== undefined && <p role="alert">{String(increment.error)}</p>}
|
|
40
|
+
</>;
|
|
32
41
|
}
|
|
33
42
|
```
|
|
34
43
|
|
|
35
|
-
`useView(source)`
|
|
44
|
+
## `useView(source)`
|
|
45
|
+
|
|
46
|
+
Returns `{ state, client, error, pending, retry }`:
|
|
36
47
|
|
|
37
48
|
- A generated page reference, or `{ connect: connect<Name> }` for a root
|
|
38
49
|
ViewModel, is connected while the component is mounted and disposed when it
|
|
@@ -41,4 +52,82 @@ export function CounterPage({ page }: { page: CounterPageReference }) {
|
|
|
41
52
|
- An already connected client is observed and left to its owner.
|
|
42
53
|
- `state` renders through `useSyncExternalStore`, so concurrent rendering sees
|
|
43
54
|
one consistent snapshot. StrictMode's extra mount disposes its connection.
|
|
44
|
-
- `
|
|
55
|
+
- `pending` is true while a reference connects. `error` holds a failed
|
|
56
|
+
connection; `retry()` connects again.
|
|
57
|
+
|
|
58
|
+
A `connect` function created during render, such as
|
|
59
|
+
`useView({ connect: () => connectWorkspace() })`, is a new reference on every
|
|
60
|
+
render, so each render reconnects. In development `useView` logs a warning when
|
|
61
|
+
this repeats. Pass the generated function itself, a generated page reference,
|
|
62
|
+
or memoize the source with `useMemo`.
|
|
63
|
+
|
|
64
|
+
## `useSuspenseView(source)`
|
|
65
|
+
|
|
66
|
+
Suspends the component until a reference connects, then returns
|
|
67
|
+
`{ state, client }` without `undefined`. A failed connection is thrown to the
|
|
68
|
+
nearest error boundary. Call `retrySuspenseView(reference)` when the boundary
|
|
69
|
+
resets, so the next render connects again; an unretried failure is forgotten
|
|
70
|
+
after ten seconds:
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
<ErrorBoundary fallback={<p role="alert">Offline</p>} onReset={() => retrySuspenseView(page)}>
|
|
74
|
+
<Suspense fallback={<p>Connecting…</p>}><Counter page={page} /></Suspense>
|
|
75
|
+
</ErrorBoundary>
|
|
76
|
+
|
|
77
|
+
function Counter({ page }: { page: CounterPageReference }) {
|
|
78
|
+
const { state, client } = useSuspenseView(page);
|
|
79
|
+
return <button onClick={() => void client.increment()}>{state.count}</button>;
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Components that pass a reference with the same `connect` function share one
|
|
84
|
+
client, which is disposed after the last of them unmounts. The reference must
|
|
85
|
+
be stable: a `connect` function created during render never resolves.
|
|
86
|
+
|
|
87
|
+
## `ViewOutlet`
|
|
88
|
+
|
|
89
|
+
`<ViewOutlet content={reference} registry={pages} fallback={…} />` renders the
|
|
90
|
+
component registered for `reference.kind` with the reference as its `page`
|
|
91
|
+
prop. Declare the registry with `satisfies ViewRegistry<State["main"]>` so each
|
|
92
|
+
kind has a component whose `page` prop matches. A different reference
|
|
93
|
+
remounts the component; a kind without a component renders an alert, and
|
|
94
|
+
`fallback` renders while `content` is empty.
|
|
95
|
+
|
|
96
|
+
## `useCommand(command)`
|
|
97
|
+
|
|
98
|
+
Returns `{ run, pending, error, failure, reset }`. `run(...args)` calls the latest
|
|
99
|
+
`command`, so it may close over the current client, and resolves to its result
|
|
100
|
+
or to `undefined` after a failure, which `error` then holds until the next run.
|
|
101
|
+
It never rejects, so handlers need no `try`/`catch`. One command can serve
|
|
102
|
+
several buttons:
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
const navigate = useCommand((name: "showWelcome" | "showCounter") => client?.[name]());
|
|
106
|
+
<button onClick={() => void navigate.run("showWelcome")}>Welcome</button>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
For a command that declares a failure (`[RunicFailure]` in .NET), `run` resolves the
|
|
110
|
+
`BridgeOutcome`, and `failure` holds the declared failure of the latest run, typed
|
|
111
|
+
from the outcome, while `error` keeps unexpected failures. Starting a run and
|
|
112
|
+
`reset()` clear both, and a run superseded by a later run or by `reset()` sets
|
|
113
|
+
neither.
|
|
114
|
+
|
|
115
|
+
## `useCollectionViewport(options)`
|
|
116
|
+
|
|
117
|
+
Follows a fixed-row-height scroll container and returns `{ viewport, ref }`.
|
|
118
|
+
`viewport` is the [`collectionViewport`](https://github.com/Runic-Artifex/runic-sdk/tree/main/packages/web/views#collectionviewportoptions)
|
|
119
|
+
range for the container; it changes only when the range or sizes change. Send
|
|
120
|
+
the range to the ViewModel from an effect:
|
|
121
|
+
|
|
122
|
+
```tsx
|
|
123
|
+
const { state, client } = useView(rows);
|
|
124
|
+
const { viewport, ref } = useCollectionViewport({ totalCount: state?.totalCount ?? 0, rowHeight: 32 });
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
if (viewport.size !== 0) void client?.setViewport({ start: viewport.start, size: viewport.size });
|
|
127
|
+
}, [client, viewport.start, viewport.size]);
|
|
128
|
+
return <div ref={ref} style={{ height: 480, overflow: "auto" }}>
|
|
129
|
+
<div style={{ height: viewport.totalSize }}>
|
|
130
|
+
<div style={{ transform: `translateY(${viewport.offset}px)` }}>{/* state.rows */}</div>
|
|
131
|
+
</div>
|
|
132
|
+
</div>;
|
|
133
|
+
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
subscribe(listener: (state: TState) => void): () => void;
|
|
5
|
-
dispose(): void;
|
|
6
|
-
}
|
|
7
|
-
/** A generated content reference, or `{ connect: connect<Name> }` for a root ViewModel. */
|
|
8
|
-
export interface ViewReference<TClient extends ViewClient = ViewClient> {
|
|
9
|
-
connect(): Promise<TClient>;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* A reference is connected and disposed by the hook. An already connected
|
|
13
|
-
* client is only observed; its owner disposes it.
|
|
14
|
-
*/
|
|
15
|
-
export type ViewSource<TClient extends ViewClient> = ViewReference<TClient> | TClient | null | undefined;
|
|
1
|
+
import { type ComponentType, type ReactNode } from "react";
|
|
2
|
+
import { type BridgeOutcomeFailure, 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";
|
|
16
4
|
export interface ViewHandle<TClient extends ViewClient> {
|
|
17
5
|
/** The latest state, or undefined until the client connects. */
|
|
18
6
|
readonly state: TClient["snapshot"] | undefined;
|
|
@@ -20,6 +8,8 @@ export interface ViewHandle<TClient extends ViewClient> {
|
|
|
20
8
|
readonly client: TClient | undefined;
|
|
21
9
|
/** The connection failure, if any. */
|
|
22
10
|
readonly error: unknown;
|
|
11
|
+
/** True while a reference is connecting. */
|
|
12
|
+
readonly pending: boolean;
|
|
23
13
|
/** Connects a reference again after a failure. */
|
|
24
14
|
retry(): void;
|
|
25
15
|
}
|
|
@@ -30,7 +20,95 @@ export interface ViewHandle<TClient extends ViewClient> {
|
|
|
30
20
|
* connection when it resolves.
|
|
31
21
|
*
|
|
32
22
|
* A reference is identified by its `connect` function, so an inline
|
|
33
|
-
* `{ connect: connectWorkspace }` does not reconnect
|
|
23
|
+
* `{ connect: connectWorkspace }` does not reconnect. In development a
|
|
24
|
+
* `connect` function recreated on every render logs a warning.
|
|
34
25
|
*/
|
|
35
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>;
|
|
52
|
+
/** A build-known map checks each generated reference kind against its component's `page` prop. */
|
|
53
|
+
export type ViewRegistry<R extends ViewReference> = {
|
|
54
|
+
readonly [K in R["kind"]]: ComponentType<{
|
|
55
|
+
readonly page: Extract<R, {
|
|
56
|
+
readonly kind: K;
|
|
57
|
+
}>;
|
|
58
|
+
}>;
|
|
59
|
+
};
|
|
60
|
+
export interface ViewOutletProps<R extends ViewReference> {
|
|
61
|
+
/** The presented reference, such as `state.main`. */
|
|
62
|
+
readonly content: R | null | undefined;
|
|
63
|
+
readonly registry: ViewRegistry<R>;
|
|
64
|
+
/** Rendered while there is no content. Defaults to nothing. */
|
|
65
|
+
readonly fallback?: ReactNode;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Renders the registered component for a generated View reference and passes
|
|
69
|
+
* the reference as its `page` prop. A different reference remounts the
|
|
70
|
+
* component. A kind without a component renders an alert.
|
|
71
|
+
*/
|
|
72
|
+
export declare function ViewOutlet<R extends ViewReference>({ content, registry, fallback }: ViewOutletProps<R>): ReactNode;
|
|
73
|
+
export interface CommandHandle<TArgs extends readonly unknown[], TResult, TFailure = BridgeOutcomeFailure<TResult>> {
|
|
74
|
+
/**
|
|
75
|
+
* Runs the command. Resolves to its result, including a `BridgeOutcome` with a
|
|
76
|
+
* declared failure, which `failure` then holds, or to undefined after an
|
|
77
|
+
* unexpected failure, which `error` then holds. Never rejects.
|
|
78
|
+
*/
|
|
79
|
+
run(...args: TArgs): Promise<TResult | undefined>;
|
|
80
|
+
/** True while a run is in flight. */
|
|
81
|
+
readonly pending: boolean;
|
|
82
|
+
/** Why the latest run failed unexpectedly, until the next run starts. */
|
|
83
|
+
readonly error: unknown;
|
|
84
|
+
/**
|
|
85
|
+
* The declared failure of the latest run, for a command that resolves a
|
|
86
|
+
* `BridgeOutcome`, until the next run starts. A superseded run sets neither.
|
|
87
|
+
*/
|
|
88
|
+
readonly failure: TFailure | undefined;
|
|
89
|
+
/** Clears `error` and `failure`. */
|
|
90
|
+
reset(): void;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Tracks a command's pending state and failure for rendering. `run` always
|
|
94
|
+
* calls the latest `command`, so it may close over the current client:
|
|
95
|
+
*
|
|
96
|
+
* ```tsx
|
|
97
|
+
* const increment = useCommand(() => client?.increment());
|
|
98
|
+
* <button disabled={!client || increment.pending} onClick={() => increment.run()}>…</button>
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
export declare function useCommand<TArgs extends readonly unknown[], TReturn>(command: (...args: TArgs) => TReturn): CommandHandle<TArgs, Awaited<TReturn>>;
|
|
102
|
+
export interface CollectionViewportHandle {
|
|
103
|
+
/** The rows to request and the sizes to render. */
|
|
104
|
+
readonly viewport: CollectionViewport;
|
|
105
|
+
/** Attach to the scroll container: `<div ref={ref}>`. */
|
|
106
|
+
readonly ref: (element: HTMLElement | null) => void;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Follows a fixed-row-height scroll container and returns the rows to request
|
|
110
|
+
* from .NET. Send `viewport.start` and `viewport.size` to the ViewModel from an
|
|
111
|
+
* effect; the hook only measures.
|
|
112
|
+
*/
|
|
113
|
+
export declare function useCollectionViewport(options: CollectionViewportOptions): CollectionViewportHandle;
|
|
36
114
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
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,EAML,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,EAC9B,KAAK,UAAU,EACf,KAAK,aAAa,EAGlB,KAAK,aAAa,EAClB,KAAK,UAAU,EAChB,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,UAAU,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAKhJ,MAAM,WAAW,UAAU,CAAC,OAAO,SAAS,UAAU;IACpD,gEAAgE;IAChE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC;IAChD,yEAAyE;IACzE,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IACrC,sCAAsC;IACtC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,4CAA4C;IAC5C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,kDAAkD;IAClD,KAAK,IAAI,IAAI,CAAC;CACf;AA6DD;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,OAAO,SAAS,UAAU,EAAE,M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;AAED,MAAM,WAAW,aAAa,CAAC,KAAK,SAAS,SAAS,OAAO,EAAE,EAAE,OAAO,EAAE,QAAQ,GAAG,oBAAoB,CAAC,OAAO,CAAC;IAChH;;;;OAIG;IACH,GAAG,CAAC,GAAG,IAAI,EAAE,KAAK,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC;IAClD,qCAAqC;IACrC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,yEAAyE;IACzE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,SAAS,CAAC;IACvC,oCAAoC;IACpC,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,KAAK,SAAS,SAAS,OAAO,EAAE,EAAE,OAAO,EAClE,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,GACnC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAOxC;AAED,MAAM,WAAW,wBAAwB;IACvC,mDAAmD;IACnD,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC;IACtC,yDAAyD;IACzD,QAAQ,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;CACrD;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,yBAAyB,GAAG,wBAAwB,CAUlG"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,56 @@
|
|
|
1
|
-
import { useCallback, useEffect, useState, useSyncExternalStore } from "react";
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { createElement, useCallback, useEffect, useInsertionEffect, useReducer, useRef, useState, useSyncExternalStore, } from "react";
|
|
2
|
+
import { createCollectionViewportController, createCommandController, createViewController, isViewClient, viewSourceIdentity, } from "@runic-artifex/views";
|
|
3
|
+
// An inline `{ connect: () => connectX() }` creates a new function on every
|
|
4
|
+
// render, so every render reconnects and each connection renders again.
|
|
5
|
+
function warnInlineConnect(tracker, connect) {
|
|
6
|
+
if (tracker.connect === connect)
|
|
7
|
+
return;
|
|
8
|
+
const text = Function.prototype.toString.call(connect);
|
|
9
|
+
const now = Date.now();
|
|
10
|
+
tracker.times = tracker.text === text ? [...tracker.times.filter(time => now - time < 1000), now] : [now];
|
|
11
|
+
tracker.connect = connect;
|
|
12
|
+
tracker.text = text;
|
|
13
|
+
if (tracker.times.length < 4 || tracker.warned)
|
|
14
|
+
return;
|
|
15
|
+
tracker.warned = true;
|
|
16
|
+
console.warn("useView reconnected repeatedly because its source's connect function is recreated on every render, " +
|
|
17
|
+
"for example `useView({ connect: () => connectWorkspace() })`. Pass a stable function such as " +
|
|
18
|
+
"`{ connect: connectWorkspace }` or a generated page reference, or memoize the source with useMemo.");
|
|
19
|
+
}
|
|
20
|
+
// The controller changes `current` silently when the effect sets its source.
|
|
21
|
+
// The store copies it and re-renders only when what the hook returns changes,
|
|
22
|
+
// so an inline connect function cannot re-render synchronously forever, and a
|
|
23
|
+
// returned client is never one the controller already released.
|
|
24
|
+
function createViewStore(controller) {
|
|
25
|
+
let snapshot = controller.current;
|
|
26
|
+
const listeners = new Set();
|
|
27
|
+
const visible = (left, right) => left.client !== right.client || left.state !== right.state || left.error !== right.error || left.pending !== right.pending;
|
|
28
|
+
// React re-renders whenever the snapshot object changes, so keep the copy
|
|
29
|
+
// unless what the hook returns changes. A copy with the same client, state,
|
|
30
|
+
// error and pending is equivalent: a released client is never current again.
|
|
31
|
+
const refresh = () => {
|
|
32
|
+
const next = controller.current;
|
|
33
|
+
if (next === snapshot || !visible(next, snapshot))
|
|
34
|
+
return;
|
|
35
|
+
snapshot = next;
|
|
36
|
+
for (const listener of [...listeners])
|
|
37
|
+
listener();
|
|
38
|
+
};
|
|
39
|
+
controller.subscribe(() => {
|
|
40
|
+
snapshot = controller.current;
|
|
41
|
+
for (const listener of [...listeners])
|
|
42
|
+
listener();
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
subscribe(onChange) {
|
|
46
|
+
listeners.add(onChange);
|
|
47
|
+
// Pick up changes made before React subscribed, such as a fast connection.
|
|
48
|
+
refresh();
|
|
49
|
+
return () => { listeners.delete(onChange); };
|
|
50
|
+
},
|
|
51
|
+
read: () => snapshot,
|
|
52
|
+
refresh,
|
|
53
|
+
};
|
|
4
54
|
}
|
|
5
55
|
/**
|
|
6
56
|
* Connects a generated View reference for the lifetime of the component and
|
|
@@ -9,42 +59,175 @@ function isClient(source) {
|
|
|
9
59
|
* connection when it resolves.
|
|
10
60
|
*
|
|
11
61
|
* A reference is identified by its `connect` function, so an inline
|
|
12
|
-
* `{ connect: connectWorkspace }` does not reconnect
|
|
62
|
+
* `{ connect: connectWorkspace }` does not reconnect. In development a
|
|
63
|
+
* `connect` function recreated on every render logs a warning.
|
|
13
64
|
*/
|
|
14
65
|
export function useView(source) {
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
|
|
66
|
+
const [controller] = useState(() => createViewController());
|
|
67
|
+
const [store] = useState(() => createViewStore(controller));
|
|
68
|
+
const tracker = useRef({ connect: undefined, text: "", times: [], warned: false });
|
|
69
|
+
const identity = viewSourceIdentity(source);
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
if (process.env.NODE_ENV !== "production" && source && !isViewClient(source))
|
|
72
|
+
warnInlineConnect(tracker.current, source.connect);
|
|
73
|
+
controller.setSource(source);
|
|
74
|
+
store.refresh();
|
|
75
|
+
// A following run refreshes the store; after unmount nothing renders it.
|
|
76
|
+
return () => { controller.setSource(null); };
|
|
77
|
+
// The source is identified by its client or connect function, not by its wrapper object.
|
|
78
|
+
}, [controller, store, identity]);
|
|
79
|
+
const current = useSyncExternalStore(store.subscribe, store.read, store.read);
|
|
80
|
+
const retry = useCallback(() => controller.retry(), [controller]);
|
|
81
|
+
const observed = source && isViewClient(source) ? source : undefined;
|
|
82
|
+
// A connected client is readable before the effect observes it.
|
|
83
|
+
if (observed && current.client !== observed)
|
|
84
|
+
return { state: observed.snapshot, client: observed, error: undefined, pending: false, retry };
|
|
85
|
+
// Until the effect follows a changed reference, do not show the previous one.
|
|
86
|
+
if (viewSourceIdentity(current.source) !== identity)
|
|
87
|
+
return { state: undefined, client: undefined, error: undefined, pending: source !== null && source !== undefined, retry };
|
|
88
|
+
return { state: current.state, client: current.client, error: current.error, pending: current.pending, retry };
|
|
89
|
+
}
|
|
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);
|
|
20
152
|
useEffect(() => {
|
|
21
|
-
if (!
|
|
153
|
+
if (!connector || !entry)
|
|
22
154
|
return;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
setConnection({ connect, attempt, client });
|
|
32
|
-
}, error => {
|
|
33
|
-
if (active)
|
|
34
|
-
setConnection({ connect, attempt, error });
|
|
35
|
-
});
|
|
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);
|
|
36
163
|
return () => {
|
|
37
|
-
|
|
38
|
-
|
|
164
|
+
entry.users--;
|
|
165
|
+
if (entry.users === 0)
|
|
166
|
+
releaseLater(key, entry, 0);
|
|
39
167
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
|
|
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
|
+
const referenceKeys = new WeakMap();
|
|
180
|
+
let nextReferenceKey = 0;
|
|
181
|
+
function referenceKey(reference) {
|
|
182
|
+
let key = referenceKeys.get(reference);
|
|
183
|
+
if (key === undefined)
|
|
184
|
+
referenceKeys.set(reference, key = ++nextReferenceKey);
|
|
185
|
+
return key;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Renders the registered component for a generated View reference and passes
|
|
189
|
+
* the reference as its `page` prop. A different reference remounts the
|
|
190
|
+
* component. A kind without a component renders an alert.
|
|
191
|
+
*/
|
|
192
|
+
export function ViewOutlet({ content, registry, fallback = null }) {
|
|
193
|
+
if (!content)
|
|
194
|
+
return fallback;
|
|
195
|
+
const component = registry[content.kind];
|
|
196
|
+
if (!component)
|
|
197
|
+
return createElement("p", { role: "alert" }, `No web component is registered for ${content.kind}.`);
|
|
198
|
+
return createElement(component, { key: referenceKey(content), page: content });
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* 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:
|
|
203
|
+
*
|
|
204
|
+
* ```tsx
|
|
205
|
+
* const increment = useCommand(() => client?.increment());
|
|
206
|
+
* <button disabled={!client || increment.pending} onClick={() => increment.run()}>…</button>
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
209
|
+
export function useCommand(command) {
|
|
210
|
+
const latest = useRef(command);
|
|
211
|
+
useInsertionEffect(() => { latest.current = command; });
|
|
212
|
+
const [controller] = useState(() => createCommandController((...args) => latest.current(...args)));
|
|
213
|
+
const read = useCallback(() => controller.current, [controller]);
|
|
214
|
+
const { pending, error, failure } = useSyncExternalStore(controller.subscribe, read, read);
|
|
215
|
+
return { run: controller.run, pending, error, failure, reset: controller.reset };
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Follows a fixed-row-height scroll container and returns the rows to request
|
|
219
|
+
* from .NET. Send `viewport.start` and `viewport.size` to the ViewModel from an
|
|
220
|
+
* effect; the hook only measures.
|
|
221
|
+
*/
|
|
222
|
+
export function useCollectionViewport(options) {
|
|
223
|
+
const [controller] = useState(() => createCollectionViewportController(options));
|
|
224
|
+
const { totalCount, rowHeight, overscan } = options;
|
|
225
|
+
useEffect(() => {
|
|
226
|
+
controller.update({ totalCount, rowHeight, ...(overscan === undefined ? {} : { overscan }) });
|
|
227
|
+
}, [controller, totalCount, rowHeight, overscan]);
|
|
228
|
+
const read = useCallback(() => controller.current, [controller]);
|
|
229
|
+
const viewport = useSyncExternalStore(controller.subscribe, read, read);
|
|
230
|
+
const ref = useCallback((element) => controller.attach(element), [controller]);
|
|
231
|
+
return { viewport, ref };
|
|
49
232
|
}
|
|
50
233
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,WAAW,EACX,SAAS,EACT,kBAAkB,EAClB,UAAU,EACV,MAAM,EACN,QAAQ,EACR,oBAAoB,GAGrB,MAAM,OAAO,CAAC;AACf,OAAO,EACL,kCAAkC,EAClC,uBAAuB,EACvB,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,GAUnB,MAAM,sBAAsB,CAAC;AAsB9B,4EAA4E;AAC5E,wEAAwE;AACxE,SAAS,iBAAiB,CAAC,OAA6B,EAAE,OAAsB;IAC9E,IAAI,OAAO,CAAC,OAAO,KAAK,OAAO;QAAE,OAAO;IACxC,MAAM,IAAI,GAAG,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACvD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAC1G,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;IAC1B,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IACpB,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,MAAM;QAAE,OAAO;IACvD,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,CAAC,IAAI,CAAC,qGAAqG;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G,QAAQ,CAAC,GAAG,EAAE,CAAC,kCAAkC,CAAC,OAAO,CAAC,CAAC,CAAC;IACjF,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACpD,SAAS,CAAC,GAAG,EAAE;QACb,UAAU,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;IAChG,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;IAClD,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IACjE,MAAM,QAAQ,GAAG,oBAAoB,CAAC,UAAU,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACxE,MAAM,GAAG,GAAG,WAAW,CAAC,CAAC,OAA2B,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IACnG,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;AAC3B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runic-artifex/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0-preview.1",
|
|
4
4
|
"description": "React hooks for generated Runic Views clients",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -24,13 +24,15 @@
|
|
|
24
24
|
"clean": "bun -e \"import('node:fs').then(({rmSync}) => rmSync('dist', { recursive: true, force: true }))\"",
|
|
25
25
|
"build": "bun run --bun clean && tsc -p tsconfig.build.json",
|
|
26
26
|
"check": "tsc -p tsconfig.json --noEmit",
|
|
27
|
-
"test": "bun run --bun build && vitest run",
|
|
27
|
+
"test": "bun run --bun build && tsc -p tsconfig.json --noEmit && vitest run",
|
|
28
28
|
"pack:check": "bun pm pack --dry-run"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"react": ">=18.3.0 <20"
|
|
31
|
+
"react": ">=18.3.0 <20",
|
|
32
|
+
"@runic-artifex/views": "0.7.0-preview.1"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
35
|
+
"@runic-artifex/views": "0.7.0-preview.1",
|
|
34
36
|
"@types/react": "19.3.0",
|
|
35
37
|
"@types/react-dom": "19.3.0",
|
|
36
38
|
"happy-dom": "20.14.5",
|
|
@@ -61,5 +63,5 @@
|
|
|
61
63
|
"views",
|
|
62
64
|
"react"
|
|
63
65
|
],
|
|
64
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "7bc41a71c8a4d22ff5855e56b51067d6c02699c1"
|
|
65
67
|
}
|