@howaboua/pi-durable-ui 0.0.0-stage → 0.9.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/LICENSE +21 -0
- package/NOTICE +10 -0
- package/README.md +132 -2
- package/dist/binding.d.ts +32 -0
- package/dist/capability.d.ts +28 -0
- package/dist/component.d.ts +18 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +631 -0
- package/dist/lifecycle.d.ts +25 -0
- package/dist/presentation.d.ts +22 -0
- package/dist/react/diff.d.ts +21 -0
- package/dist/react/diff.js +227 -0
- package/dist/remote.d.ts +19 -0
- package/dist/theme.d.ts +2 -0
- package/package.json +54 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Igor Warzocha
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Pi Durable UI SDK
|
|
2
|
+
Copyright (c) 2026 Igor Warzocha
|
|
3
|
+
|
|
4
|
+
Diff defaults and host integration contracts extracted from Howcode, MIT licensed.
|
|
5
|
+
Source: https://github.com/IgorWarzocha/howcode
|
|
6
|
+
Revision: 5c7a4e2b75c3682ce8aeb911f4dc425693507508
|
|
7
|
+
The MIT license and copyright notice are preserved in LICENSE.
|
|
8
|
+
|
|
9
|
+
Uses @pierre/diffs 1.4.3 as an external dependency, under Apache-2.0.
|
|
10
|
+
No Pierre source is vendored in this package.
|
package/README.md
CHANGED
|
@@ -1,3 +1,133 @@
|
|
|
1
|
-
#
|
|
1
|
+
# UI SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Interactive browser components backed by host-owned state, actions and streams. The root entry has no React, Git or Durable runtime import. Components run as trusted in-process code, not in a sandbox.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install https://github.com/IgorWarzocha/pi-durable-components/releases/download/v0.9.1/howaboua-pi-durable-ui-0.9.1.tgz
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Interactive components
|
|
10
|
+
|
|
11
|
+
### Headless capabilities and presentations
|
|
12
|
+
|
|
13
|
+
`UiCapability<State>` declares `id`, contract `version`, `parseState`, `actions`, `streams` and supported `presentations`. It has no renderer. `await bindCapability(capability, { id, signal, binding })` creates one instance with one binding subscription. The instance exposes its `capability` definition, `context`, `closed`, `dispose()` and `present()`.
|
|
14
|
+
|
|
15
|
+
`UiPresentation<State, Model>` declares an `id`, a semantic `select(state)` projection and allowed presentation `requests`. Different presentations share the same capability without reacquiring its binding or replaying work.
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
const instance = await bindCapability(counterCapability, {
|
|
19
|
+
id: "counter-instance", signal: lifetime.signal, binding,
|
|
20
|
+
});
|
|
21
|
+
const summary = instance.present(counterSummary, {
|
|
22
|
+
signal: viewLifetime.signal,
|
|
23
|
+
onRequestPresentation: async (id, { signal }) => {
|
|
24
|
+
await host.openPresentation(id, { signal });
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
await summary.ready;
|
|
28
|
+
summary.closed.catch(reportError);
|
|
29
|
+
// Framework-neutral store, suitable for React useSyncExternalStore:
|
|
30
|
+
const model = summary.context.state.getSnapshot();
|
|
31
|
+
await summary.context.requestPresentation("detail");
|
|
32
|
+
await summary.dispose();
|
|
33
|
+
await instance.dispose();
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Presentation contexts expose model state, capability actions and streams, and `requestPresentation(id)`. Model snapshots stay referentially stable between accepted source sequences, even when `parseState` reuses an object. A requested target must appear in both the presentation's `requests` and the capability's `presentations`. The host callback owns acquisition, placement and navigation. Requests without a callback reject. Late callback results reject after view cancellation.
|
|
37
|
+
|
|
38
|
+
Disposing a presentation cancels its work without disposing the shared capability. A projection failure closes only the affected view. Invalid source state closes the capability and all its children. Capability disposal joins child cleanup, including optional renderers. Observe each view's `closed` promise for failures.
|
|
39
|
+
|
|
40
|
+
`mountPresentation(presentation, container, { instance, signal, onRequestPresentation, mount })` is an optional DOM wrapper. Its `mount(container, context)` receives the same model context and must return a cleanup function. The returned `UiSession` owns the renderer and its presentation, not the shared capability. Headless consumers need no DOM or framework imports. Existing `mountComponent` and `mountUi` remain available.
|
|
41
|
+
|
|
42
|
+
### Mounted components
|
|
43
|
+
|
|
44
|
+
A `UiComponent<State>` declares `id`, contract `version`, `parseState`, `mount`, and the allowed `actions` and `streams`. `parseState` validates each accepted JSON snapshot and returns the component's state. `mount` receives a container and `UiComponentContext<State>` and returns a cleanup function, synchronously or asynchronously.
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import { mountComponent, type UiBinding, type UiComponent } from "@howaboua/pi-durable-ui";
|
|
48
|
+
|
|
49
|
+
const counter: UiComponent<number> = {
|
|
50
|
+
id: "counter",
|
|
51
|
+
version: 1,
|
|
52
|
+
actions: ["increment"],
|
|
53
|
+
streams: [],
|
|
54
|
+
parseState(value) {
|
|
55
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value)) {
|
|
56
|
+
throw new TypeError("Expected an integer counter");
|
|
57
|
+
}
|
|
58
|
+
return value;
|
|
59
|
+
},
|
|
60
|
+
mount(container, context) {
|
|
61
|
+
const button = document.createElement("button");
|
|
62
|
+
const render = () => { button.textContent = String(context.state.getSnapshot()); };
|
|
63
|
+
const increment = () => { void context.call("increment", null).catch(reportError); };
|
|
64
|
+
const unsubscribe = context.state.subscribe(render);
|
|
65
|
+
button.addEventListener("click", increment);
|
|
66
|
+
container.append(button);
|
|
67
|
+
render();
|
|
68
|
+
return () => {
|
|
69
|
+
unsubscribe();
|
|
70
|
+
button.removeEventListener("click", increment);
|
|
71
|
+
button.remove();
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// The host implements this binding and authorizes each action.
|
|
77
|
+
declare const binding: UiBinding;
|
|
78
|
+
const session = mountComponent(counter, container, {
|
|
79
|
+
id: "counter-instance", signal: lifetime.signal, binding,
|
|
80
|
+
});
|
|
81
|
+
session.closed.catch(reportError);
|
|
82
|
+
await session.ready;
|
|
83
|
+
// On teardown:
|
|
84
|
+
await session.dispose();
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
The host binding supplies `getSnapshot()`, `subscribe(onSnapshot, onError)`, `call(action, input, { signal })` and optional `stream(name, input, { signal })`. A snapshot is `{ sequence, value }`. Its sequence must be a nonnegative safe integer that increases within the binding's lifetime. Equal and older snapshots are ignored. The SDK subscribes before reading the initial snapshot, so a newer synchronous publication cannot be overwritten by an older initial read. Accepted values pass through `parseState` before state subscribers are notified. Keep parsed state immutable for stable snapshot reads.
|
|
88
|
+
|
|
89
|
+
The mount context exposes `id`, `signal`, `state.getSnapshot()`, `state.subscribe(listener)`, `call(action, input)` and `stream(name, input)`. The instance `id` is separate from the component definition's `id`. `version` identifies the component contract, not a state revision. The host owns discovery, contract compatibility, component loading and placement. No layout or transport is imposed.
|
|
90
|
+
|
|
91
|
+
For remote state, `await connectUiBinding(transport, { signal })` hydrates a `UiConnection` before mounting. The host-neutral `UiTransport` supplies `snapshots({ signal })`, `call` and optional `stream`. Its snapshot stream must establish the subscription before yielding the initial value, then publish updates on that same stream. This preserves updates received between hydration and mounting. A disconnect fails the binding. Observe `connection.closed` for disconnect and automatic cleanup errors. The SDK never reconnects or replays actions. After disposing the component, `await connection.close()` aborts transport work and joins the snapshot reader. It rejects an existing transport failure. The host chooses the wire protocol, authentication and authorization.
|
|
92
|
+
|
|
93
|
+
Actions and streams must appear in the component's declarations. A declared stream still requires host stream support. Consume streams with `for await`. Each consumption creates one host iterator. Disposal aborts the session signal, releases state subscriptions and requests iterator closure. Late action results and stream yields are rejected. The SDK never retries a call or resumes a stream.
|
|
94
|
+
|
|
95
|
+
Pass optional `{ signal }` as the third argument to `context.call` or `context.stream` to cancel one request while keeping the component mounted. The SDK combines that signal with the session signal. A canceled stream requests iterator closure. The host still must honor cancellation to unblock IO.
|
|
96
|
+
|
|
97
|
+
Observe `ready` for mount failures and `closed` for session failures, including invalid live state, subscription errors and cleanup errors. These failures close the session. Initialization failure releases acquired subscriptions. Cleanup runs exactly once even when a pending mount finishes after disposal. A failed mount must release resources acquired before returning its cleanup function.
|
|
98
|
+
|
|
99
|
+
Bindings must honor the supplied signal to unblock pending IO. Disposal waits for mounts and iterator cleanup, so a host or component that ignores cancellation can delay teardown. Local declarations are not permissions. The host must authorize requests and enforce remote cancellation. Aborting a session cannot undo remote side effects or establish whether an interrupted action completed. State subscriptions that throw during setup must release their own partially acquired resources.
|
|
100
|
+
|
|
101
|
+
## Low-level mounts
|
|
102
|
+
|
|
103
|
+
`mountUi` remains available for consumers that do not need live state or declared actions.
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
import { mountUi } from "@howaboua/pi-durable-ui";
|
|
107
|
+
import { mountDiff } from "@howaboua/pi-durable-ui/react/diff";
|
|
108
|
+
|
|
109
|
+
const session = mountUi(mountDiff, container, {
|
|
110
|
+
id: "git", revision: "1", signal: lifetime.signal,
|
|
111
|
+
call: (method, input) => hostRpc(method, input),
|
|
112
|
+
});
|
|
113
|
+
await session.ready;
|
|
114
|
+
session.closed.catch(reportError);
|
|
115
|
+
// On teardown:
|
|
116
|
+
await session.dispose();
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Mounts receive `{ id, revision, signal, call }` and must return a cleanup function. `mountUi` owns a child signal and invokes cleanup exactly once, even if an asynchronous mount finishes after disposal. Observe `ready` for mounting errors and `closed` for automatic cleanup errors. `dispose` aborts and waits for cleanup. A mount that fails before returning must release its own partial resources. A mount that ignores cancellation can delay disposal.
|
|
120
|
+
|
|
121
|
+
The host owns authentication, revision selection, module loading, authorization and transport. `call` carries one JSON request and response. Abort prevents new calls and rejects stale responses. It does **not** cancel remote IO or undo remote side effects. This is trusted in-process code, not a sandbox.
|
|
122
|
+
|
|
123
|
+
## Diff rendering
|
|
124
|
+
|
|
125
|
+
Install [Git](../git) 0.8.1, React and React DOM 19.3.0, and `@pierre/diffs` 1.6.1 for `/react/diff`. These are optional peers, not dependencies of the generic component API.
|
|
126
|
+
|
|
127
|
+
`DiffCodeView` preserves Pierre's generic props, imperative ref, controlled or initial items, annotation and header slots, editing provider, selection and full-file loading callbacks. `createDiffOptions` supplies shared defaults without taking ownership of host state. `parseDiffPatch` returns Pierre files, leaving ordering and fallback presentation to the host. `DiffWorkerProvider` takes a bundler-owned `workerFactory`, uses two to six workers, and keeps resource management in Pierre's provider. Hosts can supply their existing editing provider around the viewer.
|
|
128
|
+
|
|
129
|
+
`mountDiff` is an independent read-only view with loading, error and empty states and unified or split layout. It calls `git.diff` with `{}`. The host resolves the repository and returns `GitDiffResult` from the same Git reader used by agent tools. It does not replace a host's richer edit, review or image-preview interface.
|
|
130
|
+
|
|
131
|
+
`themeCss` scopes tokens to `[data-durable-ui]`: `--durable-ui-background`, `foreground`, `muted`, `border` and `accent`. It follows the system theme or a `data-theme="light"` or `"dark"` override. Hosts can override these variables for their own palette. No global page styles or font are installed.
|
|
132
|
+
|
|
133
|
+
See `examples/component-ui` for revision-anchored Git comments through a host binding. `examples/git-ui` demonstrates only the low-level read-only renderer. Neither host depends on Howcode.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { JsonValue, UiCleanup } from "./lifecycle.ts";
|
|
2
|
+
export interface UiSnapshot {
|
|
3
|
+
sequence: number;
|
|
4
|
+
value: JsonValue;
|
|
5
|
+
}
|
|
6
|
+
/** Validate wire snapshots without trusting a transport's TypeScript types. */
|
|
7
|
+
export declare function parseUiSnapshot(value: unknown): UiSnapshot;
|
|
8
|
+
/** Host-owned state and transport. Sequence numbers must be nonnegative safe integers. */
|
|
9
|
+
export interface UiBinding {
|
|
10
|
+
getSnapshot(): UiSnapshot;
|
|
11
|
+
subscribe(onSnapshot: (snapshot: UiSnapshot) => void, onError: (error: unknown) => void): UiCleanup;
|
|
12
|
+
call(action: string, input: JsonValue, options: {
|
|
13
|
+
signal: AbortSignal;
|
|
14
|
+
}): Promise<JsonValue>;
|
|
15
|
+
stream?(name: string, input: JsonValue, options: {
|
|
16
|
+
signal: AbortSignal;
|
|
17
|
+
}): AsyncIterable<JsonValue>;
|
|
18
|
+
}
|
|
19
|
+
export interface UiComponentContext<State> {
|
|
20
|
+
id: string;
|
|
21
|
+
signal: AbortSignal;
|
|
22
|
+
state: {
|
|
23
|
+
getSnapshot(): State;
|
|
24
|
+
subscribe(listener: () => void): () => void;
|
|
25
|
+
};
|
|
26
|
+
call(action: string, input: JsonValue, options?: {
|
|
27
|
+
signal?: AbortSignal;
|
|
28
|
+
}): Promise<JsonValue>;
|
|
29
|
+
stream(name: string, input: JsonValue, options?: {
|
|
30
|
+
signal?: AbortSignal;
|
|
31
|
+
}): AsyncIterable<JsonValue>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type UiBinding, type UiComponentContext } from "./binding.ts";
|
|
2
|
+
import { type JsonValue, type UiCleanup, type UiSession } from "./lifecycle.ts";
|
|
3
|
+
import { type UiPresentation, type UiPresentationContext, type UiPresentationOptions, type UiPresentationSession } from "./presentation.ts";
|
|
4
|
+
export interface UiCapability<State> {
|
|
5
|
+
id: string;
|
|
6
|
+
version: number;
|
|
7
|
+
parseState(value: JsonValue): State;
|
|
8
|
+
actions: readonly string[];
|
|
9
|
+
streams: readonly string[];
|
|
10
|
+
presentations: readonly string[];
|
|
11
|
+
}
|
|
12
|
+
export interface UiCapabilityInstance<State> {
|
|
13
|
+
capability: UiCapability<State>;
|
|
14
|
+
context: UiComponentContext<State>;
|
|
15
|
+
closed: Promise<void>;
|
|
16
|
+
dispose(): Promise<void>;
|
|
17
|
+
present<Model>(presentation: UiPresentation<State, Model>, options: UiPresentationOptions): UiPresentationSession<Model>;
|
|
18
|
+
}
|
|
19
|
+
export declare function bindCapability<State>(capability: UiCapability<State>, options: {
|
|
20
|
+
id: string;
|
|
21
|
+
signal: AbortSignal;
|
|
22
|
+
binding: UiBinding;
|
|
23
|
+
}): Promise<UiCapabilityInstance<State>>;
|
|
24
|
+
/** Optional DOM renderer. Disposing it owns its view, never the shared capability. */
|
|
25
|
+
export declare function mountPresentation<State, Model>(presentation: UiPresentation<State, Model>, container: HTMLElement, options: UiPresentationOptions & {
|
|
26
|
+
instance: UiCapabilityInstance<State>;
|
|
27
|
+
mount(container: HTMLElement, context: UiPresentationContext<Model>): UiCleanup | Promise<UiCleanup>;
|
|
28
|
+
}): UiSession;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { UiBinding, UiComponentContext } from "./binding.ts";
|
|
2
|
+
export { parseUiSnapshot, type UiBinding, type UiComponentContext, type UiSnapshot, } from "./binding.ts";
|
|
3
|
+
import { type JsonValue, type UiCleanup, type UiSession } from "./lifecycle.ts";
|
|
4
|
+
export interface UiComponent<State> {
|
|
5
|
+
id: string;
|
|
6
|
+
/** Contract version, not a state revision. */
|
|
7
|
+
version: number;
|
|
8
|
+
parseState(value: JsonValue): State;
|
|
9
|
+
mount(container: HTMLElement, context: UiComponentContext<State>): UiCleanup | Promise<UiCleanup>;
|
|
10
|
+
actions: readonly string[];
|
|
11
|
+
streams: readonly string[];
|
|
12
|
+
}
|
|
13
|
+
/** Mount trusted code against one host binding. No calls or streams are replayed. */
|
|
14
|
+
export declare function mountComponent<State>(component: UiComponent<State>, container: HTMLElement, options: {
|
|
15
|
+
id: string;
|
|
16
|
+
signal: AbortSignal;
|
|
17
|
+
binding: UiBinding;
|
|
18
|
+
}): UiSession;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { bindCapability, mountPresentation, type UiCapability, type UiCapabilityInstance, } from "./capability.ts";
|
|
2
|
+
export { mountComponent, parseUiSnapshot, type UiBinding, type UiComponent, type UiComponentContext, type UiSnapshot, } from "./component.ts";
|
|
3
|
+
export { type JsonValue, mountUi, type UiCleanup, type UiContext, type UiMount, type UiSession, } from "./lifecycle.ts";
|
|
4
|
+
export { type UiPresentation, type UiPresentationContext, type UiPresentationOptions, type UiPresentationSession, } from "./presentation.ts";
|
|
5
|
+
export { connectUiBinding, type UiConnection, type UiTransport, } from "./remote.ts";
|
|
6
|
+
export { themeCss } from "./theme.ts";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,631 @@
|
|
|
1
|
+
// packages/ui/src/binding.ts
|
|
2
|
+
function parseUiSnapshot(value) {
|
|
3
|
+
if (typeof value !== "object" || value === null || !("sequence" in value) || !("value" in value))
|
|
4
|
+
throw new TypeError("Expected a UI snapshot");
|
|
5
|
+
const sequence = value.sequence;
|
|
6
|
+
if (typeof sequence !== "number" || !Number.isSafeInteger(sequence) || sequence < 0)
|
|
7
|
+
throw new TypeError("UI snapshot sequence must be a nonnegative safe integer");
|
|
8
|
+
assertJson(value.value, new Set);
|
|
9
|
+
return { sequence, value: value.value };
|
|
10
|
+
}
|
|
11
|
+
function assertJson(value, ancestors) {
|
|
12
|
+
if (value === null || typeof value === "string" || typeof value === "boolean")
|
|
13
|
+
return;
|
|
14
|
+
if (typeof value === "number" && Number.isFinite(value))
|
|
15
|
+
return;
|
|
16
|
+
if (typeof value !== "object" || value === null || ancestors.has(value))
|
|
17
|
+
throw new TypeError("UI snapshot value must be JSON");
|
|
18
|
+
if (!Array.isArray(value) && Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null)
|
|
19
|
+
throw new TypeError("UI snapshot value must be JSON");
|
|
20
|
+
ancestors.add(value);
|
|
21
|
+
if (Array.isArray(value)) {
|
|
22
|
+
for (const entry of value)
|
|
23
|
+
assertJson(entry, ancestors);
|
|
24
|
+
} else {
|
|
25
|
+
for (const entry of Object.values(value))
|
|
26
|
+
assertJson(entry, ancestors);
|
|
27
|
+
}
|
|
28
|
+
ancestors.delete(value);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// packages/ui/src/lifecycle.ts
|
|
32
|
+
function mountUi(mount, container, context) {
|
|
33
|
+
return ownUiSession((signal) => mount(container, {
|
|
34
|
+
...context,
|
|
35
|
+
signal,
|
|
36
|
+
async call(method, input) {
|
|
37
|
+
signal.throwIfAborted();
|
|
38
|
+
const result = await context.call(method, input);
|
|
39
|
+
signal.throwIfAborted();
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
}), context.signal);
|
|
43
|
+
}
|
|
44
|
+
function ownUiSession(start, parentSignal, options) {
|
|
45
|
+
const controller = new AbortController;
|
|
46
|
+
let finish;
|
|
47
|
+
let fail;
|
|
48
|
+
const closed = new Promise((resolve, reject) => {
|
|
49
|
+
finish = resolve;
|
|
50
|
+
fail = reject;
|
|
51
|
+
});
|
|
52
|
+
closed.catch(() => {});
|
|
53
|
+
let disposing;
|
|
54
|
+
const mounted = Promise.resolve().then(async () => {
|
|
55
|
+
if (controller.signal.aborted && !options?.startWhenAborted)
|
|
56
|
+
return;
|
|
57
|
+
const cleanup = await start(controller.signal);
|
|
58
|
+
if (typeof cleanup !== "function")
|
|
59
|
+
throw new TypeError("UI mount must return a cleanup function");
|
|
60
|
+
return cleanup;
|
|
61
|
+
});
|
|
62
|
+
const dispose = () => {
|
|
63
|
+
if (disposing)
|
|
64
|
+
return disposing;
|
|
65
|
+
disposing = mounted.then((cleanup) => cleanup?.()).then(finish, (error) => {
|
|
66
|
+
fail(error);
|
|
67
|
+
throw error;
|
|
68
|
+
});
|
|
69
|
+
parentSignal.removeEventListener("abort", abort);
|
|
70
|
+
controller.abort();
|
|
71
|
+
return disposing;
|
|
72
|
+
};
|
|
73
|
+
const abort = () => {
|
|
74
|
+
dispose().catch(() => {});
|
|
75
|
+
};
|
|
76
|
+
parentSignal.addEventListener("abort", abort, { once: true });
|
|
77
|
+
if (parentSignal.aborted)
|
|
78
|
+
abort();
|
|
79
|
+
const ready = mounted.then(() => {
|
|
80
|
+
controller.signal.throwIfAborted();
|
|
81
|
+
});
|
|
82
|
+
ready.catch((error) => {
|
|
83
|
+
if (!controller.signal.aborted) {
|
|
84
|
+
controller.abort();
|
|
85
|
+
parentSignal.removeEventListener("abort", abort);
|
|
86
|
+
fail(error);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
return { ready, closed, dispose };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// packages/ui/src/presentation.ts
|
|
93
|
+
function createPresentation(presentation, source, revision, presentations, options) {
|
|
94
|
+
const controller = new AbortController;
|
|
95
|
+
const signal = AbortSignal.any([
|
|
96
|
+
source.signal,
|
|
97
|
+
options.signal,
|
|
98
|
+
controller.signal
|
|
99
|
+
]);
|
|
100
|
+
const listeners = new Set;
|
|
101
|
+
const iterators = new Set;
|
|
102
|
+
let sequence = -1;
|
|
103
|
+
let model;
|
|
104
|
+
let failure;
|
|
105
|
+
let failed = false;
|
|
106
|
+
let unsubscribe;
|
|
107
|
+
let session;
|
|
108
|
+
const select = () => {
|
|
109
|
+
signal.throwIfAborted();
|
|
110
|
+
if (sequence !== revision()) {
|
|
111
|
+
try {
|
|
112
|
+
model = presentation.select(source.state.getSnapshot());
|
|
113
|
+
sequence = revision();
|
|
114
|
+
} catch (error) {
|
|
115
|
+
failure = error;
|
|
116
|
+
failed = true;
|
|
117
|
+
controller.abort();
|
|
118
|
+
throw error;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return model;
|
|
122
|
+
};
|
|
123
|
+
const update = () => {
|
|
124
|
+
try {
|
|
125
|
+
select();
|
|
126
|
+
for (const listener of [...listeners]) {
|
|
127
|
+
if (signal.aborted)
|
|
128
|
+
break;
|
|
129
|
+
listener();
|
|
130
|
+
}
|
|
131
|
+
} catch (error) {
|
|
132
|
+
failure = error;
|
|
133
|
+
failed = true;
|
|
134
|
+
controller.abort();
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
select();
|
|
138
|
+
unsubscribe = source.state.subscribe(update);
|
|
139
|
+
const release = () => {
|
|
140
|
+
unsubscribe?.();
|
|
141
|
+
unsubscribe = undefined;
|
|
142
|
+
listeners.clear();
|
|
143
|
+
};
|
|
144
|
+
signal.addEventListener("abort", release, { once: true });
|
|
145
|
+
session = ownUiSession(() => async () => {
|
|
146
|
+
release();
|
|
147
|
+
signal.removeEventListener("abort", release);
|
|
148
|
+
const results = await Promise.allSettled([...iterators].map((iterator) => iterator.return?.()));
|
|
149
|
+
const errors = results.flatMap((result) => result.status === "rejected" ? [result.reason] : []);
|
|
150
|
+
if (failed)
|
|
151
|
+
errors.unshift(failure);
|
|
152
|
+
if (errors.length)
|
|
153
|
+
throw new AggregateError(errors, "UI presentation failed");
|
|
154
|
+
}, signal, { startWhenAborted: true });
|
|
155
|
+
const context = {
|
|
156
|
+
id: source.id,
|
|
157
|
+
signal,
|
|
158
|
+
state: {
|
|
159
|
+
getSnapshot: select,
|
|
160
|
+
subscribe(listener) {
|
|
161
|
+
signal.throwIfAborted();
|
|
162
|
+
listeners.add(listener);
|
|
163
|
+
return () => {
|
|
164
|
+
listeners.delete(listener);
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
call(action, input, request) {
|
|
169
|
+
return source.call(action, input, {
|
|
170
|
+
signal: request?.signal ? AbortSignal.any([signal, request.signal]) : signal
|
|
171
|
+
});
|
|
172
|
+
},
|
|
173
|
+
async* stream(name, input, request) {
|
|
174
|
+
const iterator = source.stream(name, input, {
|
|
175
|
+
signal: request?.signal ? AbortSignal.any([signal, request.signal]) : signal
|
|
176
|
+
})[Symbol.asyncIterator]();
|
|
177
|
+
iterators.add(iterator);
|
|
178
|
+
try {
|
|
179
|
+
while (true) {
|
|
180
|
+
const next = await iterator.next();
|
|
181
|
+
if (next.done)
|
|
182
|
+
break;
|
|
183
|
+
yield next.value;
|
|
184
|
+
}
|
|
185
|
+
} finally {
|
|
186
|
+
try {
|
|
187
|
+
await iterator.return?.();
|
|
188
|
+
} finally {
|
|
189
|
+
iterators.delete(iterator);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
async requestPresentation(id) {
|
|
194
|
+
signal.throwIfAborted();
|
|
195
|
+
if (!presentation.requests.includes(id) || !presentations.includes(id))
|
|
196
|
+
throw new Error(`Undeclared UI presentation request: ${id}`);
|
|
197
|
+
if (!options.onRequestPresentation)
|
|
198
|
+
throw new Error("UI host does not handle presentation requests");
|
|
199
|
+
await options.onRequestPresentation(id, { signal });
|
|
200
|
+
signal.throwIfAborted();
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
const closed = session.closed.then(() => {
|
|
204
|
+
if (failed)
|
|
205
|
+
throw failure;
|
|
206
|
+
});
|
|
207
|
+
closed.catch(() => {});
|
|
208
|
+
return {
|
|
209
|
+
...session,
|
|
210
|
+
closed,
|
|
211
|
+
context,
|
|
212
|
+
async dispose() {
|
|
213
|
+
controller.abort();
|
|
214
|
+
await session.dispose();
|
|
215
|
+
await closed;
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// packages/ui/src/capability.ts
|
|
221
|
+
var ownedChildren = new WeakMap;
|
|
222
|
+
function ownCapabilityChild(instance, child) {
|
|
223
|
+
const children = ownedChildren.get(instance);
|
|
224
|
+
if (!children)
|
|
225
|
+
throw new Error("Unknown UI capability instance");
|
|
226
|
+
children.add(child);
|
|
227
|
+
child.closed.catch(() => {}).finally(() => children.delete(child));
|
|
228
|
+
}
|
|
229
|
+
async function bindCapability(capability, options) {
|
|
230
|
+
const actions = new Set(capability.actions);
|
|
231
|
+
const streams = new Set(capability.streams);
|
|
232
|
+
const binding = options.binding;
|
|
233
|
+
const children = new Set;
|
|
234
|
+
let context;
|
|
235
|
+
let revision;
|
|
236
|
+
let session;
|
|
237
|
+
session = ownUiSession(async (signal) => {
|
|
238
|
+
const listeners = new Set;
|
|
239
|
+
const iterators = new Map;
|
|
240
|
+
const pending = new Set;
|
|
241
|
+
const errors = [];
|
|
242
|
+
let unsubscribe;
|
|
243
|
+
let sequence = -1;
|
|
244
|
+
let state;
|
|
245
|
+
const track = (cleanup) => {
|
|
246
|
+
try {
|
|
247
|
+
const task = Promise.resolve(cleanup()).catch((error) => {
|
|
248
|
+
errors.push(error);
|
|
249
|
+
}).finally(() => {
|
|
250
|
+
pending.delete(task);
|
|
251
|
+
});
|
|
252
|
+
pending.add(task);
|
|
253
|
+
} catch (error) {
|
|
254
|
+
errors.push(error);
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
const closeIterator = (iterator) => {
|
|
258
|
+
const existing = iterators.get(iterator);
|
|
259
|
+
if (existing)
|
|
260
|
+
return existing;
|
|
261
|
+
const closing = Promise.resolve().then(async () => {
|
|
262
|
+
await iterator.return?.();
|
|
263
|
+
});
|
|
264
|
+
iterators.set(iterator, closing);
|
|
265
|
+
track(() => closing);
|
|
266
|
+
return closing;
|
|
267
|
+
};
|
|
268
|
+
const release = () => {
|
|
269
|
+
listeners.clear();
|
|
270
|
+
for (const child of children)
|
|
271
|
+
track(() => child.dispose());
|
|
272
|
+
children.clear();
|
|
273
|
+
const cleanup = unsubscribe;
|
|
274
|
+
unsubscribe = undefined;
|
|
275
|
+
if (cleanup)
|
|
276
|
+
track(cleanup);
|
|
277
|
+
for (const iterator of iterators.keys())
|
|
278
|
+
closeIterator(iterator);
|
|
279
|
+
};
|
|
280
|
+
const finish = async () => {
|
|
281
|
+
release();
|
|
282
|
+
signal.removeEventListener("abort", release);
|
|
283
|
+
await Promise.all(pending);
|
|
284
|
+
if (errors.length)
|
|
285
|
+
throw new AggregateError(errors, "UI component session failed");
|
|
286
|
+
};
|
|
287
|
+
const fail = (error) => {
|
|
288
|
+
if (signal.aborted)
|
|
289
|
+
return;
|
|
290
|
+
errors.push(error);
|
|
291
|
+
session.dispose().catch(() => {});
|
|
292
|
+
};
|
|
293
|
+
const accept = (snapshot) => {
|
|
294
|
+
if (signal.aborted)
|
|
295
|
+
return;
|
|
296
|
+
try {
|
|
297
|
+
const validated = parseUiSnapshot(snapshot);
|
|
298
|
+
if (validated.sequence <= sequence)
|
|
299
|
+
return;
|
|
300
|
+
const parsed = capability.parseState(validated.value);
|
|
301
|
+
state = parsed;
|
|
302
|
+
sequence = validated.sequence;
|
|
303
|
+
for (const listener of [...listeners]) {
|
|
304
|
+
if (signal.aborted)
|
|
305
|
+
break;
|
|
306
|
+
listener();
|
|
307
|
+
}
|
|
308
|
+
} catch (error) {
|
|
309
|
+
fail(error);
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
signal.addEventListener("abort", release, { once: true });
|
|
313
|
+
try {
|
|
314
|
+
unsubscribe = binding.subscribe(accept, fail);
|
|
315
|
+
if (typeof unsubscribe !== "function")
|
|
316
|
+
throw new TypeError("UI binding must return a cleanup function");
|
|
317
|
+
signal.throwIfAborted();
|
|
318
|
+
accept(binding.getSnapshot());
|
|
319
|
+
signal.throwIfAborted();
|
|
320
|
+
context = {
|
|
321
|
+
id: options.id,
|
|
322
|
+
signal,
|
|
323
|
+
state: {
|
|
324
|
+
getSnapshot() {
|
|
325
|
+
signal.throwIfAborted();
|
|
326
|
+
return state;
|
|
327
|
+
},
|
|
328
|
+
subscribe(listener) {
|
|
329
|
+
signal.throwIfAborted();
|
|
330
|
+
listeners.add(listener);
|
|
331
|
+
return () => {
|
|
332
|
+
listeners.delete(listener);
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
async call(action, input, options) {
|
|
337
|
+
const requestSignal = options?.signal ? AbortSignal.any([signal, options.signal]) : signal;
|
|
338
|
+
requestSignal.throwIfAborted();
|
|
339
|
+
if (!actions.has(action))
|
|
340
|
+
throw new Error(`Undeclared UI action: ${action}`);
|
|
341
|
+
const result = await binding.call(action, input, {
|
|
342
|
+
signal: requestSignal
|
|
343
|
+
});
|
|
344
|
+
requestSignal.throwIfAborted();
|
|
345
|
+
return result;
|
|
346
|
+
},
|
|
347
|
+
async* stream(name, input, options) {
|
|
348
|
+
const requestSignal = options?.signal ? AbortSignal.any([signal, options.signal]) : signal;
|
|
349
|
+
requestSignal.throwIfAborted();
|
|
350
|
+
if (!streams.has(name))
|
|
351
|
+
throw new Error(`Undeclared UI stream: ${name}`);
|
|
352
|
+
if (!binding.stream)
|
|
353
|
+
throw new Error("UI binding does not support streams");
|
|
354
|
+
const iterator = binding.stream(name, input, { signal: requestSignal })[Symbol.asyncIterator]();
|
|
355
|
+
iterators.set(iterator, undefined);
|
|
356
|
+
const cancel = () => {
|
|
357
|
+
closeIterator(iterator).catch(() => {});
|
|
358
|
+
};
|
|
359
|
+
requestSignal.addEventListener("abort", cancel, { once: true });
|
|
360
|
+
if (requestSignal.aborted)
|
|
361
|
+
cancel();
|
|
362
|
+
try {
|
|
363
|
+
while (true) {
|
|
364
|
+
requestSignal.throwIfAborted();
|
|
365
|
+
const next = await iterator.next();
|
|
366
|
+
requestSignal.throwIfAborted();
|
|
367
|
+
if (next.done)
|
|
368
|
+
break;
|
|
369
|
+
yield next.value;
|
|
370
|
+
}
|
|
371
|
+
} finally {
|
|
372
|
+
requestSignal.removeEventListener("abort", cancel);
|
|
373
|
+
try {
|
|
374
|
+
await closeIterator(iterator);
|
|
375
|
+
} finally {
|
|
376
|
+
iterators.delete(iterator);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
revision = () => sequence;
|
|
382
|
+
} catch (error) {
|
|
383
|
+
errors.push(error);
|
|
384
|
+
session.dispose().catch(() => {});
|
|
385
|
+
await finish();
|
|
386
|
+
throw error;
|
|
387
|
+
}
|
|
388
|
+
return async () => {
|
|
389
|
+
await finish();
|
|
390
|
+
};
|
|
391
|
+
}, options.signal);
|
|
392
|
+
await session.ready;
|
|
393
|
+
const instance = {
|
|
394
|
+
capability,
|
|
395
|
+
context,
|
|
396
|
+
closed: session.closed,
|
|
397
|
+
dispose: session.dispose,
|
|
398
|
+
present(presentation, viewOptions) {
|
|
399
|
+
context.signal.throwIfAborted();
|
|
400
|
+
if (!capability.presentations.includes(presentation.id))
|
|
401
|
+
throw new Error(`Undeclared UI presentation: ${presentation.id}`);
|
|
402
|
+
const view = createPresentation(presentation, context, revision, capability.presentations, viewOptions);
|
|
403
|
+
ownCapabilityChild(instance, view);
|
|
404
|
+
return view;
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
ownedChildren.set(instance, children);
|
|
408
|
+
return instance;
|
|
409
|
+
}
|
|
410
|
+
function mountPresentation(presentation, container, options) {
|
|
411
|
+
let session;
|
|
412
|
+
session = ownUiSession(async (signal) => {
|
|
413
|
+
const view = options.instance.present(presentation, {
|
|
414
|
+
...options,
|
|
415
|
+
signal
|
|
416
|
+
});
|
|
417
|
+
view.closed.catch(() => session.dispose().catch(() => {}));
|
|
418
|
+
try {
|
|
419
|
+
await view.ready;
|
|
420
|
+
const cleanup = await options.mount(container, view.context);
|
|
421
|
+
if (typeof cleanup !== "function")
|
|
422
|
+
throw new TypeError("UI mount must return a cleanup function");
|
|
423
|
+
return async () => {
|
|
424
|
+
try {
|
|
425
|
+
await cleanup();
|
|
426
|
+
} finally {
|
|
427
|
+
await view.dispose();
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
} catch (error) {
|
|
431
|
+
await view.dispose();
|
|
432
|
+
throw error;
|
|
433
|
+
}
|
|
434
|
+
}, AbortSignal.any([options.signal, options.instance.context.signal]));
|
|
435
|
+
ownCapabilityChild(options.instance, session);
|
|
436
|
+
return session;
|
|
437
|
+
}
|
|
438
|
+
// packages/ui/src/component.ts
|
|
439
|
+
function mountComponent(component, container, options) {
|
|
440
|
+
let session;
|
|
441
|
+
session = ownUiSession(async (signal) => {
|
|
442
|
+
const instance = await bindCapability({ ...component, presentations: [] }, { ...options, signal });
|
|
443
|
+
instance.closed.catch(() => session.dispose().catch(() => {}));
|
|
444
|
+
try {
|
|
445
|
+
const cleanup = await component.mount(container, instance.context);
|
|
446
|
+
if (typeof cleanup !== "function")
|
|
447
|
+
throw new TypeError("UI mount must return a cleanup function");
|
|
448
|
+
return async () => {
|
|
449
|
+
try {
|
|
450
|
+
await cleanup();
|
|
451
|
+
} finally {
|
|
452
|
+
await instance.dispose();
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
} catch (error) {
|
|
456
|
+
await instance.dispose();
|
|
457
|
+
throw error;
|
|
458
|
+
}
|
|
459
|
+
}, options.signal);
|
|
460
|
+
return session;
|
|
461
|
+
}
|
|
462
|
+
// packages/ui/src/remote.ts
|
|
463
|
+
async function connectUiBinding(transport, options) {
|
|
464
|
+
const controller = new AbortController;
|
|
465
|
+
const abort = () => controller.abort(options.signal.reason);
|
|
466
|
+
options.signal.addEventListener("abort", abort, { once: true });
|
|
467
|
+
if (options.signal.aborted)
|
|
468
|
+
abort();
|
|
469
|
+
const signal = controller.signal;
|
|
470
|
+
const listeners = new Set;
|
|
471
|
+
let snapshot;
|
|
472
|
+
let failure;
|
|
473
|
+
let reader;
|
|
474
|
+
let pumping = Promise.resolve();
|
|
475
|
+
let started = false;
|
|
476
|
+
let closing;
|
|
477
|
+
const close = () => {
|
|
478
|
+
if (closing)
|
|
479
|
+
return closing;
|
|
480
|
+
closing = Promise.resolve().then(async () => {
|
|
481
|
+
if (!started)
|
|
482
|
+
await reader?.return?.();
|
|
483
|
+
await pumping;
|
|
484
|
+
});
|
|
485
|
+
controller.abort();
|
|
486
|
+
options.signal.removeEventListener("abort", abort);
|
|
487
|
+
listeners.clear();
|
|
488
|
+
return closing;
|
|
489
|
+
};
|
|
490
|
+
try {
|
|
491
|
+
signal.throwIfAborted();
|
|
492
|
+
reader = transport.snapshots({ signal })[Symbol.asyncIterator]();
|
|
493
|
+
const initial = await reader.next();
|
|
494
|
+
signal.throwIfAborted();
|
|
495
|
+
if (initial.done)
|
|
496
|
+
throw new Error("UI snapshot stream ended before hydration");
|
|
497
|
+
snapshot = parseUiSnapshot(initial.value);
|
|
498
|
+
} catch (error) {
|
|
499
|
+
try {
|
|
500
|
+
await close();
|
|
501
|
+
} catch (cleanupError) {
|
|
502
|
+
throw new AggregateError([error, cleanupError], "UI connection failed");
|
|
503
|
+
}
|
|
504
|
+
throw error;
|
|
505
|
+
}
|
|
506
|
+
const activeReader = reader;
|
|
507
|
+
started = true;
|
|
508
|
+
pumping = (async () => {
|
|
509
|
+
try {
|
|
510
|
+
while (!signal.aborted) {
|
|
511
|
+
const item = await activeReader.next();
|
|
512
|
+
if (signal.aborted)
|
|
513
|
+
break;
|
|
514
|
+
if (item.done)
|
|
515
|
+
throw new Error("UI snapshot stream disconnected");
|
|
516
|
+
const update = parseUiSnapshot(item.value);
|
|
517
|
+
if (update.sequence <= snapshot.sequence)
|
|
518
|
+
continue;
|
|
519
|
+
snapshot = update;
|
|
520
|
+
for (const listener of [...listeners])
|
|
521
|
+
listener.next(snapshot);
|
|
522
|
+
}
|
|
523
|
+
} catch (error) {
|
|
524
|
+
if (!signal.aborted) {
|
|
525
|
+
failure = { error };
|
|
526
|
+
controller.abort(error);
|
|
527
|
+
const errors = [error];
|
|
528
|
+
for (const listener of [...listeners]) {
|
|
529
|
+
try {
|
|
530
|
+
listener.error(error);
|
|
531
|
+
} catch (observerError) {
|
|
532
|
+
errors.push(observerError);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
throw errors.length === 1 ? error : new AggregateError(errors, "UI connection observers failed");
|
|
536
|
+
}
|
|
537
|
+
} finally {
|
|
538
|
+
options.signal.removeEventListener("abort", abort);
|
|
539
|
+
listeners.clear();
|
|
540
|
+
await activeReader.return?.();
|
|
541
|
+
}
|
|
542
|
+
})();
|
|
543
|
+
pumping.catch(() => {});
|
|
544
|
+
function check() {
|
|
545
|
+
if (failure)
|
|
546
|
+
throw failure.error;
|
|
547
|
+
signal.throwIfAborted();
|
|
548
|
+
}
|
|
549
|
+
return {
|
|
550
|
+
closed: pumping,
|
|
551
|
+
getSnapshot() {
|
|
552
|
+
check();
|
|
553
|
+
return snapshot;
|
|
554
|
+
},
|
|
555
|
+
subscribe(next, error) {
|
|
556
|
+
check();
|
|
557
|
+
const listener = { next, error };
|
|
558
|
+
listeners.add(listener);
|
|
559
|
+
return () => {
|
|
560
|
+
listeners.delete(listener);
|
|
561
|
+
};
|
|
562
|
+
},
|
|
563
|
+
async call(action, input, invocation) {
|
|
564
|
+
check();
|
|
565
|
+
const callSignal = AbortSignal.any([signal, invocation.signal]);
|
|
566
|
+
callSignal.throwIfAborted();
|
|
567
|
+
const result = await transport.call(action, input, {
|
|
568
|
+
signal: callSignal
|
|
569
|
+
});
|
|
570
|
+
callSignal.throwIfAborted();
|
|
571
|
+
return result;
|
|
572
|
+
},
|
|
573
|
+
...transport.stream ? {
|
|
574
|
+
async* stream(name, input, invocation) {
|
|
575
|
+
check();
|
|
576
|
+
const streamSignal = AbortSignal.any([signal, invocation.signal]);
|
|
577
|
+
streamSignal.throwIfAborted();
|
|
578
|
+
const stream = transport.stream;
|
|
579
|
+
if (!stream)
|
|
580
|
+
throw new Error("UI transport does not support streams");
|
|
581
|
+
for await (const value of stream(name, input, {
|
|
582
|
+
signal: streamSignal
|
|
583
|
+
})) {
|
|
584
|
+
streamSignal.throwIfAborted();
|
|
585
|
+
yield value;
|
|
586
|
+
}
|
|
587
|
+
streamSignal.throwIfAborted();
|
|
588
|
+
}
|
|
589
|
+
} : {},
|
|
590
|
+
close
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
// packages/ui/src/theme.ts
|
|
594
|
+
var themeCss = `
|
|
595
|
+
[data-durable-ui] {
|
|
596
|
+
color-scheme: light dark;
|
|
597
|
+
--durable-ui-background: #fff;
|
|
598
|
+
--durable-ui-foreground: #24292f;
|
|
599
|
+
--durable-ui-muted: #57606a;
|
|
600
|
+
--durable-ui-border: #d0d7de;
|
|
601
|
+
--durable-ui-accent: #0969da;
|
|
602
|
+
color: var(--durable-ui-foreground);
|
|
603
|
+
background: var(--durable-ui-background);
|
|
604
|
+
}
|
|
605
|
+
@media (prefers-color-scheme: dark) {
|
|
606
|
+
[data-durable-ui]:not([data-theme="light"]) {
|
|
607
|
+
--durable-ui-background: #161b22;
|
|
608
|
+
--durable-ui-foreground: #e6edf3;
|
|
609
|
+
--durable-ui-muted: #9da7b3;
|
|
610
|
+
--durable-ui-border: #444c56;
|
|
611
|
+
--durable-ui-accent: #79c0ff;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
[data-durable-ui][data-theme="dark"] {
|
|
615
|
+
--durable-ui-background: #161b22;
|
|
616
|
+
--durable-ui-foreground: #e6edf3;
|
|
617
|
+
--durable-ui-muted: #9da7b3;
|
|
618
|
+
--durable-ui-border: #444c56;
|
|
619
|
+
--durable-ui-accent: #79c0ff;
|
|
620
|
+
}
|
|
621
|
+
[data-durable-ui] :focus-visible { outline: 2px solid var(--durable-ui-accent); outline-offset: 3px; }
|
|
622
|
+
`;
|
|
623
|
+
export {
|
|
624
|
+
bindCapability,
|
|
625
|
+
connectUiBinding,
|
|
626
|
+
mountComponent,
|
|
627
|
+
mountPresentation,
|
|
628
|
+
mountUi,
|
|
629
|
+
parseUiSnapshot,
|
|
630
|
+
themeCss
|
|
631
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type JsonValue = null | boolean | number | string | readonly JsonValue[] | {
|
|
2
|
+
readonly [key: string]: JsonValue;
|
|
3
|
+
};
|
|
4
|
+
/** Trusted in-process UI. call transport and authorization belong to the host. */
|
|
5
|
+
export interface UiContext {
|
|
6
|
+
id: string;
|
|
7
|
+
revision: string;
|
|
8
|
+
signal: AbortSignal;
|
|
9
|
+
call(method: string, input: JsonValue): Promise<JsonValue>;
|
|
10
|
+
}
|
|
11
|
+
export type UiCleanup = () => void | Promise<void>;
|
|
12
|
+
export type UiMount = (container: HTMLElement, context: UiContext) => UiCleanup | Promise<UiCleanup>;
|
|
13
|
+
export interface UiSession {
|
|
14
|
+
/** Rejects on failed mount or disposal before mount completes. */
|
|
15
|
+
ready: Promise<void>;
|
|
16
|
+
/** Observe failures here, including automatic parent-signal cleanup. */
|
|
17
|
+
closed: Promise<void>;
|
|
18
|
+
dispose(): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
/** Own one mount, its child signal, and exactly one cleanup, including late mounts. */
|
|
21
|
+
export declare function mountUi(mount: UiMount, container: HTMLElement, context: UiContext): UiSession;
|
|
22
|
+
/** Internal lifecycle owner shared by bindings, views and DOM mounts. */
|
|
23
|
+
export declare function ownUiSession(start: (signal: AbortSignal) => UiCleanup | Promise<UiCleanup>, parentSignal: AbortSignal, options?: {
|
|
24
|
+
startWhenAborted?: boolean;
|
|
25
|
+
}): UiSession;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { UiComponentContext } from "./binding.ts";
|
|
2
|
+
import { type UiSession } from "./lifecycle.ts";
|
|
3
|
+
/** Semantic projection, independent of rendering or placement. */
|
|
4
|
+
export interface UiPresentation<State, Model> {
|
|
5
|
+
id: string;
|
|
6
|
+
select(state: State): Model;
|
|
7
|
+
requests: readonly string[];
|
|
8
|
+
}
|
|
9
|
+
export interface UiPresentationOptions {
|
|
10
|
+
signal: AbortSignal;
|
|
11
|
+
onRequestPresentation?: (id: string, options: {
|
|
12
|
+
signal: AbortSignal;
|
|
13
|
+
}) => void | Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export interface UiPresentationContext<Model> extends UiComponentContext<Model> {
|
|
16
|
+
requestPresentation(id: string): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export interface UiPresentationSession<Model> extends UiSession {
|
|
19
|
+
context: UiPresentationContext<Model>;
|
|
20
|
+
}
|
|
21
|
+
/** Internal view owner. A projection failure closes only this view. */
|
|
22
|
+
export declare function createPresentation<State, Model>(presentation: UiPresentation<State, Model>, source: UiComponentContext<State>, revision: () => number, presentations: readonly string[], options: UiPresentationOptions): UiPresentationSession<Model>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type FileDiffMetadata } from "@pierre/diffs";
|
|
2
|
+
import { type CodeViewHandle, type CodeViewProps, type CodeViewReactOptions } from "@pierre/diffs/react";
|
|
3
|
+
import { type ReactNode, type Ref } from "react";
|
|
4
|
+
import type { UiMount } from "../index.ts";
|
|
5
|
+
export declare const diffThemes: {
|
|
6
|
+
readonly light: "pierre-light";
|
|
7
|
+
readonly dark: "pierre-dark";
|
|
8
|
+
};
|
|
9
|
+
/** Shared viewer defaults, not host editing, annotation, selection, or hydration state. */
|
|
10
|
+
export declare function createDiffOptions<Annotation = undefined, Caret = undefined>(overrides?: CodeViewReactOptions<Annotation, Caret>): CodeViewReactOptions<Annotation, Caret>;
|
|
11
|
+
export declare function DiffCodeView<Annotation = undefined, Caret = undefined>(props: CodeViewProps<Annotation, Caret> & {
|
|
12
|
+
ref?: Ref<CodeViewHandle<Annotation, Caret>>;
|
|
13
|
+
}): import("react").JSX.Element;
|
|
14
|
+
/** Supply a bundler-owned worker factory. No fixed asset URLs or worker startup at import. */
|
|
15
|
+
export declare function DiffWorkerProvider({ workerFactory, children, }: {
|
|
16
|
+
workerFactory: () => Worker;
|
|
17
|
+
children: ReactNode;
|
|
18
|
+
}): import("react").JSX.Element;
|
|
19
|
+
export declare function parseDiffPatch(patch: string, cacheKey?: string): FileDiffMetadata[];
|
|
20
|
+
/** Standalone trusted-package mount. The host resolves and authorizes git.diff's repository. */
|
|
21
|
+
export declare const mountDiff: UiMount;
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
// packages/ui/src/react/diff.tsx
|
|
2
|
+
import {
|
|
3
|
+
parseGitDiffResult
|
|
4
|
+
} from "@howaboua/pi-durable-git/contracts";
|
|
5
|
+
import { parsePatchFiles } from "@pierre/diffs";
|
|
6
|
+
import {
|
|
7
|
+
CodeView,
|
|
8
|
+
WorkerPoolContextProvider
|
|
9
|
+
} from "@pierre/diffs/react";
|
|
10
|
+
import { useEffect, useMemo, useState } from "react";
|
|
11
|
+
import { createRoot } from "react-dom/client";
|
|
12
|
+
|
|
13
|
+
// packages/ui/src/theme.ts
|
|
14
|
+
var themeCss = `
|
|
15
|
+
[data-durable-ui] {
|
|
16
|
+
color-scheme: light dark;
|
|
17
|
+
--durable-ui-background: #fff;
|
|
18
|
+
--durable-ui-foreground: #24292f;
|
|
19
|
+
--durable-ui-muted: #57606a;
|
|
20
|
+
--durable-ui-border: #d0d7de;
|
|
21
|
+
--durable-ui-accent: #0969da;
|
|
22
|
+
color: var(--durable-ui-foreground);
|
|
23
|
+
background: var(--durable-ui-background);
|
|
24
|
+
}
|
|
25
|
+
@media (prefers-color-scheme: dark) {
|
|
26
|
+
[data-durable-ui]:not([data-theme="light"]) {
|
|
27
|
+
--durable-ui-background: #161b22;
|
|
28
|
+
--durable-ui-foreground: #e6edf3;
|
|
29
|
+
--durable-ui-muted: #9da7b3;
|
|
30
|
+
--durable-ui-border: #444c56;
|
|
31
|
+
--durable-ui-accent: #79c0ff;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
[data-durable-ui][data-theme="dark"] {
|
|
35
|
+
--durable-ui-background: #161b22;
|
|
36
|
+
--durable-ui-foreground: #e6edf3;
|
|
37
|
+
--durable-ui-muted: #9da7b3;
|
|
38
|
+
--durable-ui-border: #444c56;
|
|
39
|
+
--durable-ui-accent: #79c0ff;
|
|
40
|
+
}
|
|
41
|
+
[data-durable-ui] :focus-visible { outline: 2px solid var(--durable-ui-accent); outline-offset: 3px; }
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
// packages/ui/src/react/diff.tsx
|
|
45
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
46
|
+
var diffThemes = {
|
|
47
|
+
light: "pierre-light",
|
|
48
|
+
dark: "pierre-dark"
|
|
49
|
+
};
|
|
50
|
+
function createDiffOptions(overrides = {}) {
|
|
51
|
+
return {
|
|
52
|
+
diffStyle: "unified",
|
|
53
|
+
lineDiffType: "none",
|
|
54
|
+
overflow: "wrap",
|
|
55
|
+
theme: diffThemes,
|
|
56
|
+
themeType: "system",
|
|
57
|
+
preferredHighlighter: "highlights",
|
|
58
|
+
lineHoverHighlight: "both",
|
|
59
|
+
itemMetrics: {
|
|
60
|
+
lineHeight: 20,
|
|
61
|
+
diffHeaderHeight: 36,
|
|
62
|
+
hunkSeparatorHeight: 8
|
|
63
|
+
},
|
|
64
|
+
layout: { gap: 8, paddingTop: 0, paddingBottom: 8 },
|
|
65
|
+
...overrides
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function DiffCodeView(props) {
|
|
69
|
+
const options = useMemo(() => createDiffOptions(props.options), [props.options]);
|
|
70
|
+
return /* @__PURE__ */ jsx(CodeView, {
|
|
71
|
+
...props,
|
|
72
|
+
options
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function DiffWorkerProvider({
|
|
76
|
+
workerFactory,
|
|
77
|
+
children
|
|
78
|
+
}) {
|
|
79
|
+
const poolOptions = useMemo(() => ({
|
|
80
|
+
workerFactory,
|
|
81
|
+
poolSize: Math.max(2, Math.min(6, Math.floor((typeof navigator === "undefined" ? 4 : navigator.hardwareConcurrency || 4) / 2))),
|
|
82
|
+
totalASTLRUCacheSize: 100
|
|
83
|
+
}), [workerFactory]);
|
|
84
|
+
return /* @__PURE__ */ jsx(WorkerPoolContextProvider, {
|
|
85
|
+
poolOptions,
|
|
86
|
+
highlighterOptions: {
|
|
87
|
+
theme: diffThemes,
|
|
88
|
+
tokenizeMaxLineLength: 1000,
|
|
89
|
+
preferredHighlighter: "highlights"
|
|
90
|
+
},
|
|
91
|
+
children
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function parseDiffPatch(patch, cacheKey) {
|
|
95
|
+
if (!patch.trim())
|
|
96
|
+
return [];
|
|
97
|
+
const files = parsePatchFiles(patch.trim(), cacheKey).flatMap((parsed) => parsed.files);
|
|
98
|
+
return files;
|
|
99
|
+
}
|
|
100
|
+
function DiffPanel({ context }) {
|
|
101
|
+
const [state, setState] = useState({ kind: "loading" });
|
|
102
|
+
const [style, setStyle] = useState("unified");
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
const lifetime = new AbortController;
|
|
105
|
+
const signal = AbortSignal.any([lifetime.signal, context.signal]);
|
|
106
|
+
context.call("git.diff", {}).then(parseGitDiffResult).then((result) => {
|
|
107
|
+
signal.throwIfAborted();
|
|
108
|
+
setState({ kind: "ready", result, files: parseDiffPatch(result.diff) });
|
|
109
|
+
}).catch((error) => {
|
|
110
|
+
if (!signal.aborted)
|
|
111
|
+
setState({
|
|
112
|
+
kind: "error",
|
|
113
|
+
message: error instanceof Error ? error.message : String(error)
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
return () => lifetime.abort();
|
|
117
|
+
}, [context]);
|
|
118
|
+
const files = state.kind === "ready" ? state.files : undefined;
|
|
119
|
+
const items = useMemo(() => files?.map((fileDiff, index) => ({
|
|
120
|
+
type: "diff",
|
|
121
|
+
id: `${index}:${fileDiff.name}`,
|
|
122
|
+
fileDiff
|
|
123
|
+
})), [files]);
|
|
124
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
125
|
+
"data-durable-ui": "",
|
|
126
|
+
"aria-label": "Git diff",
|
|
127
|
+
style: {
|
|
128
|
+
display: "flex",
|
|
129
|
+
flexDirection: "column",
|
|
130
|
+
height: "100%",
|
|
131
|
+
minHeight: 0,
|
|
132
|
+
font: "14px/1.5 system-ui, sans-serif"
|
|
133
|
+
},
|
|
134
|
+
children: [
|
|
135
|
+
/* @__PURE__ */ jsx("style", {
|
|
136
|
+
children: themeCss
|
|
137
|
+
}),
|
|
138
|
+
/* @__PURE__ */ jsxs("header", {
|
|
139
|
+
style: {
|
|
140
|
+
padding: "12px 16px",
|
|
141
|
+
borderBottom: "1px solid var(--durable-ui-border)",
|
|
142
|
+
display: "flex",
|
|
143
|
+
flexWrap: "wrap",
|
|
144
|
+
gap: 16,
|
|
145
|
+
alignItems: "center"
|
|
146
|
+
},
|
|
147
|
+
children: [
|
|
148
|
+
/* @__PURE__ */ jsx("h2", {
|
|
149
|
+
style: { margin: 0, fontSize: 16 },
|
|
150
|
+
children: "Changes"
|
|
151
|
+
}),
|
|
152
|
+
state.kind === "ready" && /* @__PURE__ */ jsxs("span", {
|
|
153
|
+
children: [
|
|
154
|
+
state.result.fileCount,
|
|
155
|
+
" files, +",
|
|
156
|
+
state.result.insertions,
|
|
157
|
+
" −",
|
|
158
|
+
state.result.deletions
|
|
159
|
+
]
|
|
160
|
+
}),
|
|
161
|
+
/* @__PURE__ */ jsxs("label", {
|
|
162
|
+
style: { marginLeft: "auto" },
|
|
163
|
+
children: [
|
|
164
|
+
"Layout",
|
|
165
|
+
" ",
|
|
166
|
+
/* @__PURE__ */ jsxs("select", {
|
|
167
|
+
value: style,
|
|
168
|
+
onChange: (event) => setStyle(event.target.value === "split" ? "split" : "unified"),
|
|
169
|
+
children: [
|
|
170
|
+
/* @__PURE__ */ jsx("option", {
|
|
171
|
+
value: "unified",
|
|
172
|
+
children: "Unified"
|
|
173
|
+
}),
|
|
174
|
+
/* @__PURE__ */ jsx("option", {
|
|
175
|
+
value: "split",
|
|
176
|
+
children: "Split"
|
|
177
|
+
})
|
|
178
|
+
]
|
|
179
|
+
})
|
|
180
|
+
]
|
|
181
|
+
})
|
|
182
|
+
]
|
|
183
|
+
}),
|
|
184
|
+
state.kind === "loading" && /* @__PURE__ */ jsx("p", {
|
|
185
|
+
role: "status",
|
|
186
|
+
children: "Loading changes"
|
|
187
|
+
}),
|
|
188
|
+
state.kind === "error" && /* @__PURE__ */ jsx("p", {
|
|
189
|
+
role: "alert",
|
|
190
|
+
children: state.message
|
|
191
|
+
}),
|
|
192
|
+
state.kind === "ready" && (items?.length ? /* @__PURE__ */ jsx(DiffCodeView, {
|
|
193
|
+
items,
|
|
194
|
+
options: { diffStyle: style },
|
|
195
|
+
style: { flex: 1, minHeight: 0 }
|
|
196
|
+
}) : state.result.diff.trim() ? /* @__PURE__ */ jsxs("div", {
|
|
197
|
+
style: { overflow: "auto" },
|
|
198
|
+
children: [
|
|
199
|
+
/* @__PURE__ */ jsx("p", {
|
|
200
|
+
children: "Unsupported diff format. Showing the raw patch."
|
|
201
|
+
}),
|
|
202
|
+
/* @__PURE__ */ jsx("pre", {
|
|
203
|
+
children: state.result.diff
|
|
204
|
+
})
|
|
205
|
+
]
|
|
206
|
+
}) : /* @__PURE__ */ jsx("p", {
|
|
207
|
+
children: "No changes."
|
|
208
|
+
}))
|
|
209
|
+
]
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
var mountDiff = (container, context) => {
|
|
213
|
+
context.signal.throwIfAborted();
|
|
214
|
+
const root = createRoot(container);
|
|
215
|
+
root.render(/* @__PURE__ */ jsx(DiffPanel, {
|
|
216
|
+
context
|
|
217
|
+
}));
|
|
218
|
+
return () => root.unmount();
|
|
219
|
+
};
|
|
220
|
+
export {
|
|
221
|
+
DiffCodeView,
|
|
222
|
+
DiffWorkerProvider,
|
|
223
|
+
createDiffOptions,
|
|
224
|
+
diffThemes,
|
|
225
|
+
mountDiff,
|
|
226
|
+
parseDiffPatch
|
|
227
|
+
};
|
package/dist/remote.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type UiBinding, type UiSnapshot } from "./binding.ts";
|
|
2
|
+
/** The snapshot stream must subscribe before yielding its initial snapshot. */
|
|
3
|
+
export interface UiTransport {
|
|
4
|
+
snapshots(options: {
|
|
5
|
+
signal: AbortSignal;
|
|
6
|
+
}): AsyncIterable<UiSnapshot>;
|
|
7
|
+
call: UiBinding["call"];
|
|
8
|
+
stream?: UiBinding["stream"];
|
|
9
|
+
}
|
|
10
|
+
export interface UiConnection extends UiBinding {
|
|
11
|
+
/** Observe disconnects and automatic cleanup failures. */
|
|
12
|
+
closed: Promise<void>;
|
|
13
|
+
/** Abort transport work and join the snapshot reader. Never replays actions. */
|
|
14
|
+
close(): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
/** Hydrate a binding from a host transport without losing updates during mounting. */
|
|
17
|
+
export declare function connectUiBinding(transport: UiTransport, options: {
|
|
18
|
+
signal: AbortSignal;
|
|
19
|
+
}): Promise<UiConnection>;
|
package/dist/theme.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** Scoped tokens. Hosts may override them without installing global page styles. */
|
|
2
|
+
export declare const themeCss = "\n[data-durable-ui] {\n color-scheme: light dark;\n --durable-ui-background: #fff;\n --durable-ui-foreground: #24292f;\n --durable-ui-muted: #57606a;\n --durable-ui-border: #d0d7de;\n --durable-ui-accent: #0969da;\n color: var(--durable-ui-foreground);\n background: var(--durable-ui-background);\n}\n@media (prefers-color-scheme: dark) {\n [data-durable-ui]:not([data-theme=\"light\"]) {\n --durable-ui-background: #161b22;\n --durable-ui-foreground: #e6edf3;\n --durable-ui-muted: #9da7b3;\n --durable-ui-border: #444c56;\n --durable-ui-accent: #79c0ff;\n }\n}\n[data-durable-ui][data-theme=\"dark\"] {\n --durable-ui-background: #161b22;\n --durable-ui-foreground: #e6edf3;\n --durable-ui-muted: #9da7b3;\n --durable-ui-border: #444c56;\n --durable-ui-accent: #79c0ff;\n}\n[data-durable-ui] :focus-visible { outline: 2px solid var(--durable-ui-accent); outline-offset: 3px; }\n";
|
package/package.json
CHANGED
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@howaboua/pi-durable-ui",
|
|
3
|
+
"version": "0.9.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/IgorWarzocha/pi-durable-components.git",
|
|
9
|
+
"directory": "packages/ui"
|
|
10
|
+
},
|
|
11
|
+
"author": "Igor Warzocha",
|
|
12
|
+
"main": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md",
|
|
17
|
+
"NOTICE",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"description": "Interactive component SDK with live state, actions, streams and host-owned capabilities",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"import": "./dist/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./react/diff": {
|
|
31
|
+
"types": "./dist/react/diff.d.ts",
|
|
32
|
+
"import": "./dist/react/diff.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@howaboua/pi-durable-git": "0.9.1",
|
|
37
|
+
"@pierre/diffs": "1.6.1",
|
|
38
|
+
"react": "19.3.0",
|
|
39
|
+
"react-dom": "19.3.0"
|
|
40
|
+
},
|
|
41
|
+
"peerDependenciesMeta": {
|
|
42
|
+
"@howaboua/pi-durable-git": {
|
|
43
|
+
"optional": true
|
|
44
|
+
},
|
|
45
|
+
"@pierre/diffs": {
|
|
46
|
+
"optional": true
|
|
47
|
+
},
|
|
48
|
+
"react": {
|
|
49
|
+
"optional": true
|
|
50
|
+
},
|
|
51
|
+
"react-dom": {
|
|
52
|
+
"optional": true
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|