oui-spec 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +94 -122
- package/dist/{chunk-CVUUSPF4.js → chunk-BMCL2K74.js} +2 -2
- package/dist/chunk-BMCL2K74.js.map +1 -0
- package/dist/{chunk-MTMEW6MM.cjs → chunk-DCVVTP3V.cjs} +72 -23
- package/dist/chunk-DCVVTP3V.cjs.map +1 -0
- package/dist/chunk-DGMKSJTY.cjs +573 -0
- package/dist/chunk-DGMKSJTY.cjs.map +1 -0
- package/dist/chunk-F3SKRAGU.cjs +98 -0
- package/dist/chunk-F3SKRAGU.cjs.map +1 -0
- package/dist/{chunk-YDMGV72W.js → chunk-F3WKIRAU.js} +72 -23
- package/dist/chunk-F3WKIRAU.js.map +1 -0
- package/dist/chunk-GXTNZ44I.js +569 -0
- package/dist/chunk-GXTNZ44I.js.map +1 -0
- package/dist/chunk-IIZ6HL2L.js +89 -0
- package/dist/chunk-IIZ6HL2L.js.map +1 -0
- package/dist/chunk-NYCJZQSP.js +92 -0
- package/dist/chunk-NYCJZQSP.js.map +1 -0
- package/dist/chunk-ROGKEMLL.cjs +91 -0
- package/dist/chunk-ROGKEMLL.cjs.map +1 -0
- package/dist/{chunk-3DCIL4FV.cjs → chunk-ZKM4XWAB.cjs} +2 -2
- package/dist/chunk-ZKM4XWAB.cjs.map +1 -0
- package/dist/core/index.cjs +10 -6
- package/dist/core/index.d.cts +15 -8
- package/dist/core/index.d.ts +15 -8
- package/dist/core/index.js +3 -3
- package/dist/index.cjs +28 -12
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +5 -5
- package/dist/react/index.cjs +15 -3
- package/dist/react/index.d.cts +33 -50
- package/dist/react/index.d.ts +33 -50
- package/dist/react/index.js +1 -1
- package/dist/spec/index.cjs +2 -2
- package/dist/spec/index.d.cts +35 -7
- package/dist/spec/index.d.ts +35 -7
- package/dist/spec/index.js +1 -1
- package/dist/{define-surface-D6XPtoqu.d.cts → surface-runtime-BzIKgL_I.d.cts} +102 -2
- package/dist/{define-surface-DXBop-uB.d.ts → surface-runtime-DeByfbKg.d.ts} +102 -2
- package/dist/transport/index.cjs +4 -4
- package/dist/transport/index.d.cts +2 -2
- package/dist/transport/index.d.ts +2 -2
- package/dist/transport/index.js +2 -2
- package/dist/{websocket-CrI0yRNo.d.cts → websocket-YfWILdZ4.d.cts} +36 -18
- package/dist/{websocket-CiWvkaz_.d.ts → websocket-c5tIUWY5.d.ts} +36 -18
- package/package.json +5 -1
- package/spec/OUI-SPEC-v0.1.md +229 -155
- package/dist/chunk-2ON5IEXB.cjs +0 -167
- package/dist/chunk-2ON5IEXB.cjs.map +0 -1
- package/dist/chunk-3DCIL4FV.cjs.map +0 -1
- package/dist/chunk-5TQ6AVQH.cjs +0 -108
- package/dist/chunk-5TQ6AVQH.cjs.map +0 -1
- package/dist/chunk-CVUUSPF4.js.map +0 -1
- package/dist/chunk-HK7OXB2W.cjs +0 -157
- package/dist/chunk-HK7OXB2W.cjs.map +0 -1
- package/dist/chunk-ILUTAHUJ.js +0 -154
- package/dist/chunk-ILUTAHUJ.js.map +0 -1
- package/dist/chunk-MTMEW6MM.cjs.map +0 -1
- package/dist/chunk-O6EI77LD.js +0 -106
- package/dist/chunk-O6EI77LD.js.map +0 -1
- package/dist/chunk-UIGRLZOX.js +0 -164
- package/dist/chunk-UIGRLZOX.js.map +0 -1
- package/dist/chunk-YDMGV72W.js.map +0 -1
package/dist/core/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { createOUI, defineSurface } from '../chunk-
|
|
2
|
-
export { OUI_PROTOCOL_EVENTS } from '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
export { createOUI, createSurfaceRuntime, defineSurface } from '../chunk-GXTNZ44I.js';
|
|
2
|
+
export { OUI_PROTOCOL_EVENTS } from '../chunk-BMCL2K74.js';
|
|
3
|
+
import '../chunk-F3WKIRAU.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -1,40 +1,56 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
3
|
+
var chunkDGMKSJTY_cjs = require('./chunk-DGMKSJTY.cjs');
|
|
4
|
+
var chunkZKM4XWAB_cjs = require('./chunk-ZKM4XWAB.cjs');
|
|
5
|
+
var chunkF3SKRAGU_cjs = require('./chunk-F3SKRAGU.cjs');
|
|
6
|
+
var chunkROGKEMLL_cjs = require('./chunk-ROGKEMLL.cjs');
|
|
7
|
+
var chunkDCVVTP3V_cjs = require('./chunk-DCVVTP3V.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
Object.defineProperty(exports, "createOUI", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkDGMKSJTY_cjs.createOUI; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "createSurfaceRuntime", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkDGMKSJTY_cjs.createSurfaceRuntime; }
|
|
14
18
|
});
|
|
15
19
|
Object.defineProperty(exports, "defineSurface", {
|
|
16
20
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunkDGMKSJTY_cjs.defineSurface; }
|
|
18
22
|
});
|
|
19
23
|
Object.defineProperty(exports, "OUI_PROTOCOL_EVENTS", {
|
|
20
24
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkZKM4XWAB_cjs.OUI_PROTOCOL_EVENTS; }
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(exports, "SurfaceRuntimeProvider", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () { return chunkF3SKRAGU_cjs.SurfaceRuntimeProvider; }
|
|
22
30
|
});
|
|
23
31
|
Object.defineProperty(exports, "useObservation", {
|
|
24
32
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
33
|
+
get: function () { return chunkF3SKRAGU_cjs.useObservation; }
|
|
26
34
|
});
|
|
27
35
|
Object.defineProperty(exports, "useSurface", {
|
|
28
36
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
37
|
+
get: function () { return chunkF3SKRAGU_cjs.useSurface; }
|
|
38
|
+
});
|
|
39
|
+
Object.defineProperty(exports, "useSurfaceHold", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function () { return chunkF3SKRAGU_cjs.useSurfaceHold; }
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(exports, "useSurfaceRuntime", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () { return chunkF3SKRAGU_cjs.useSurfaceRuntime; }
|
|
30
46
|
});
|
|
31
47
|
Object.defineProperty(exports, "createDirectTransportPair", {
|
|
32
48
|
enumerable: true,
|
|
33
|
-
get: function () { return
|
|
49
|
+
get: function () { return chunkROGKEMLL_cjs.createDirectTransportPair; }
|
|
34
50
|
});
|
|
35
51
|
Object.defineProperty(exports, "createWebSocketTransport", {
|
|
36
52
|
enumerable: true,
|
|
37
|
-
get: function () { return
|
|
53
|
+
get: function () { return chunkDCVVTP3V_cjs.createWebSocketTransport; }
|
|
38
54
|
});
|
|
39
55
|
//# sourceMappingURL=index.cjs.map
|
|
40
56
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { JSONSchema, OUIAction, OUIActionPolling, OUIActionRequest, OUIActionResult, OUIActivation, OUIObservation, OUIObservationUpdate, OUIProtocolEvent, OUISurface, OUISurfaceDeregistration, OUISurfaceRegistration, OUI_PROTOCOL_EVENTS } from './spec/index.cjs';
|
|
2
|
-
export { A as ActionDefinition, a as ActionHandlerResult, b as ActionPollingConfig, D as DefinedSurface, O as OUIBranded, c as ObservationDefinition, S as
|
|
1
|
+
export { JSONSchema, OUIAction, OUIActionPolling, OUIActionRequest, OUIActionResult, OUIActivation, OUIObservation, OUIObservationSnapshot, OUIObservationUpdate, OUIProtocolEvent, OUISurface, OUISurfaceDeregistration, OUISurfaceRegistration, OUISurfaceSnapshot, OUI_PROTOCOL_EVENTS } from './spec/index.cjs';
|
|
2
|
+
export { A as ActionDefinition, a as ActionHandlerResult, b as ActionPollingConfig, D as DefinedSurface, M as MountedSurface, O as OUIBranded, c as ObservationDefinition, S as SettleOptions, d as SurfaceDefinition, e as SurfaceRuntime, f as SurfaceRuntimeOptions, g as createSurfaceRuntime, h as defineSurface } from './surface-runtime-BzIKgL_I.cjs';
|
|
3
3
|
export { DuplicateIds, OUIConfig, OUIConfigError, OUIInstance, OwnedTransport, ValidateSurfaceIds, createOUI } from './core/index.cjs';
|
|
4
|
-
export { UseSurfaceOptions, useObservation, useSurface } from './react/index.cjs';
|
|
5
|
-
export { O as OUIActionHandler, a as OUIObservationHandler, b as
|
|
4
|
+
export { SurfaceRuntimeProvider, SurfaceRuntimeProviderProps, UseSurfaceOptions, UseSurfaceResult, useObservation, useSurface, useSurfaceHold, useSurfaceRuntime } from './react/index.cjs';
|
|
5
|
+
export { O as OUIActionHandler, a as OUIObservationHandler, b as OUIResultHandler, c as OUITransport, d as OUITransportConfig, S as SocketLike, e as createWebSocketTransport } from './websocket-YfWILdZ4.cjs';
|
|
6
6
|
export { createDirectTransportPair } from './transport/index.cjs';
|
|
7
|
+
import 'react';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { JSONSchema, OUIAction, OUIActionPolling, OUIActionRequest, OUIActionResult, OUIActivation, OUIObservation, OUIObservationUpdate, OUIProtocolEvent, OUISurface, OUISurfaceDeregistration, OUISurfaceRegistration, OUI_PROTOCOL_EVENTS } from './spec/index.js';
|
|
2
|
-
export { A as ActionDefinition, a as ActionHandlerResult, b as ActionPollingConfig, D as DefinedSurface, O as OUIBranded, c as ObservationDefinition, S as
|
|
1
|
+
export { JSONSchema, OUIAction, OUIActionPolling, OUIActionRequest, OUIActionResult, OUIActivation, OUIObservation, OUIObservationSnapshot, OUIObservationUpdate, OUIProtocolEvent, OUISurface, OUISurfaceDeregistration, OUISurfaceRegistration, OUISurfaceSnapshot, OUI_PROTOCOL_EVENTS } from './spec/index.js';
|
|
2
|
+
export { A as ActionDefinition, a as ActionHandlerResult, b as ActionPollingConfig, D as DefinedSurface, M as MountedSurface, O as OUIBranded, c as ObservationDefinition, S as SettleOptions, d as SurfaceDefinition, e as SurfaceRuntime, f as SurfaceRuntimeOptions, g as createSurfaceRuntime, h as defineSurface } from './surface-runtime-DeByfbKg.js';
|
|
3
3
|
export { DuplicateIds, OUIConfig, OUIConfigError, OUIInstance, OwnedTransport, ValidateSurfaceIds, createOUI } from './core/index.js';
|
|
4
|
-
export { UseSurfaceOptions, useObservation, useSurface } from './react/index.js';
|
|
5
|
-
export { O as OUIActionHandler, a as OUIObservationHandler, b as
|
|
4
|
+
export { SurfaceRuntimeProvider, SurfaceRuntimeProviderProps, UseSurfaceOptions, UseSurfaceResult, useObservation, useSurface, useSurfaceHold, useSurfaceRuntime } from './react/index.js';
|
|
5
|
+
export { O as OUIActionHandler, a as OUIObservationHandler, b as OUIResultHandler, c as OUITransport, d as OUITransportConfig, S as SocketLike, e as createWebSocketTransport } from './websocket-c5tIUWY5.js';
|
|
6
6
|
export { createDirectTransportPair } from './transport/index.js';
|
|
7
|
+
import 'react';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { createOUI, defineSurface } from './chunk-
|
|
2
|
-
export { OUI_PROTOCOL_EVENTS } from './chunk-
|
|
3
|
-
export { useObservation, useSurface } from './chunk-
|
|
4
|
-
export { createDirectTransportPair } from './chunk-
|
|
5
|
-
export { createWebSocketTransport } from './chunk-
|
|
1
|
+
export { createOUI, createSurfaceRuntime, defineSurface } from './chunk-GXTNZ44I.js';
|
|
2
|
+
export { OUI_PROTOCOL_EVENTS } from './chunk-BMCL2K74.js';
|
|
3
|
+
export { SurfaceRuntimeProvider, useObservation, useSurface, useSurfaceHold, useSurfaceRuntime } from './chunk-NYCJZQSP.js';
|
|
4
|
+
export { createDirectTransportPair } from './chunk-IIZ6HL2L.js';
|
|
5
|
+
export { createWebSocketTransport } from './chunk-F3WKIRAU.js';
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
package/dist/react/index.cjs
CHANGED
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkF3SKRAGU_cjs = require('../chunk-F3SKRAGU.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
+
Object.defineProperty(exports, "SurfaceRuntimeProvider", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkF3SKRAGU_cjs.SurfaceRuntimeProvider; }
|
|
10
|
+
});
|
|
7
11
|
Object.defineProperty(exports, "useObservation", {
|
|
8
12
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkF3SKRAGU_cjs.useObservation; }
|
|
10
14
|
});
|
|
11
15
|
Object.defineProperty(exports, "useSurface", {
|
|
12
16
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunkF3SKRAGU_cjs.useSurface; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "useSurfaceHold", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return chunkF3SKRAGU_cjs.useSurfaceHold; }
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, "useSurfaceRuntime", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return chunkF3SKRAGU_cjs.useSurfaceRuntime; }
|
|
14
26
|
});
|
|
15
27
|
//# sourceMappingURL=index.cjs.map
|
|
16
28
|
//# sourceMappingURL=index.cjs.map
|
package/dist/react/index.d.cts
CHANGED
|
@@ -1,62 +1,45 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { OUIActionResult } from '../spec/index.cjs';
|
|
4
|
+
import { e as SurfaceRuntime, D as DefinedSurface } from '../surface-runtime-BzIKgL_I.cjs';
|
|
5
|
+
import '../websocket-YfWILdZ4.cjs';
|
|
3
6
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
interface SurfaceRuntimeProviderProps {
|
|
8
|
+
runtime: SurfaceRuntime;
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
/** Makes one surface runtime available to every `useSurface` below it. */
|
|
12
|
+
declare function SurfaceRuntimeProvider({ runtime, children, }: SurfaceRuntimeProviderProps): react.FunctionComponentElement<react.ProviderProps<SurfaceRuntime | null>>;
|
|
13
|
+
/** The surface runtime from the nearest `SurfaceRuntimeProvider`. */
|
|
14
|
+
declare function useSurfaceRuntime(): SurfaceRuntime;
|
|
7
15
|
interface UseSurfaceOptions<TContext> {
|
|
8
16
|
/** The defined surface (from defineSurface()) */
|
|
9
17
|
surface: DefinedSurface<TContext>;
|
|
10
|
-
/**
|
|
18
|
+
/** Passed to action handlers. Read when an action runs, so it is always current. */
|
|
11
19
|
context: TContext;
|
|
12
|
-
/**
|
|
13
|
-
send: (event: {
|
|
14
|
-
type: string;
|
|
15
|
-
payload: unknown;
|
|
16
|
-
}) => void;
|
|
17
|
-
/** Whether the surface is currently active (respects activation conditions) */
|
|
20
|
+
/** Mount the surface only while true. Default true. */
|
|
18
21
|
active?: boolean;
|
|
19
22
|
}
|
|
23
|
+
interface UseSurfaceResult {
|
|
24
|
+
surfaceId: string;
|
|
25
|
+
/** Record an observation value on this surface. Unchanged values are ignored. */
|
|
26
|
+
pushObservation(observationId: string, value: unknown): void;
|
|
27
|
+
/** Run one of this surface's actions locally, exactly as a dispatched request would. */
|
|
28
|
+
execute(actionId: string, params?: Record<string, unknown>): Promise<OUIActionResult>;
|
|
29
|
+
}
|
|
20
30
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* After an action handler executes, if the action has a polling config, the
|
|
26
|
-
* hook starts a polling loop that pushes observation updates until the
|
|
27
|
-
* operation completes or times out.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* ```tsx
|
|
31
|
-
* function DataVizPage() {
|
|
32
|
-
* const { state, updateState, goToStep } = useDataVizWizard();
|
|
33
|
-
*
|
|
34
|
-
* useSurface({
|
|
35
|
-
* surface: datavizSurface,
|
|
36
|
-
* context: { state, updateState, goToStep },
|
|
37
|
-
* send: agentTransport.send,
|
|
38
|
-
* active: true,
|
|
39
|
-
* });
|
|
40
|
-
*
|
|
41
|
-
* return <DataVizWizard />;
|
|
42
|
-
* }
|
|
43
|
-
* ```
|
|
31
|
+
* Mount a surface into the client's surface runtime for as long as the
|
|
32
|
+
* component is mounted (and `active`). The runtime answers dispatched requests
|
|
33
|
+
* for it, so the component needs no listener of its own.
|
|
44
34
|
*/
|
|
45
|
-
declare function useSurface<TContext>(options: UseSurfaceOptions<TContext>):
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
manifest: OUISurface;
|
|
49
|
-
/** Manually stop polling for a specific action */
|
|
50
|
-
stopPolling: (actionId: string) => void;
|
|
51
|
-
/** Stop all active pollers */
|
|
52
|
-
stopAllPolling: () => void;
|
|
53
|
-
};
|
|
35
|
+
declare function useSurface<TContext>(options: UseSurfaceOptions<TContext>): UseSurfaceResult;
|
|
36
|
+
/** Keep an observation on a mounted surface equal to `value`. */
|
|
37
|
+
declare function useObservation(surface: Pick<UseSurfaceResult, "pushObservation">, observationId: string, value: unknown): void;
|
|
54
38
|
/**
|
|
55
|
-
*
|
|
39
|
+
* Keep the UI unsettled while `busy` is true: an action's result waits for it.
|
|
40
|
+
* For work mounting cannot show, such as a route's code or a page's data still
|
|
41
|
+
* loading.
|
|
56
42
|
*/
|
|
57
|
-
declare function
|
|
58
|
-
type: string;
|
|
59
|
-
payload: unknown;
|
|
60
|
-
}) => void): void;
|
|
43
|
+
declare function useSurfaceHold(busy: boolean): void;
|
|
61
44
|
|
|
62
|
-
export { type UseSurfaceOptions, useObservation, useSurface };
|
|
45
|
+
export { SurfaceRuntimeProvider, type SurfaceRuntimeProviderProps, type UseSurfaceOptions, type UseSurfaceResult, useObservation, useSurface, useSurfaceHold, useSurfaceRuntime };
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,62 +1,45 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { OUIActionResult } from '../spec/index.js';
|
|
4
|
+
import { e as SurfaceRuntime, D as DefinedSurface } from '../surface-runtime-DeByfbKg.js';
|
|
5
|
+
import '../websocket-c5tIUWY5.js';
|
|
3
6
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
interface SurfaceRuntimeProviderProps {
|
|
8
|
+
runtime: SurfaceRuntime;
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
/** Makes one surface runtime available to every `useSurface` below it. */
|
|
12
|
+
declare function SurfaceRuntimeProvider({ runtime, children, }: SurfaceRuntimeProviderProps): react.FunctionComponentElement<react.ProviderProps<SurfaceRuntime | null>>;
|
|
13
|
+
/** The surface runtime from the nearest `SurfaceRuntimeProvider`. */
|
|
14
|
+
declare function useSurfaceRuntime(): SurfaceRuntime;
|
|
7
15
|
interface UseSurfaceOptions<TContext> {
|
|
8
16
|
/** The defined surface (from defineSurface()) */
|
|
9
17
|
surface: DefinedSurface<TContext>;
|
|
10
|
-
/**
|
|
18
|
+
/** Passed to action handlers. Read when an action runs, so it is always current. */
|
|
11
19
|
context: TContext;
|
|
12
|
-
/**
|
|
13
|
-
send: (event: {
|
|
14
|
-
type: string;
|
|
15
|
-
payload: unknown;
|
|
16
|
-
}) => void;
|
|
17
|
-
/** Whether the surface is currently active (respects activation conditions) */
|
|
20
|
+
/** Mount the surface only while true. Default true. */
|
|
18
21
|
active?: boolean;
|
|
19
22
|
}
|
|
23
|
+
interface UseSurfaceResult {
|
|
24
|
+
surfaceId: string;
|
|
25
|
+
/** Record an observation value on this surface. Unchanged values are ignored. */
|
|
26
|
+
pushObservation(observationId: string, value: unknown): void;
|
|
27
|
+
/** Run one of this surface's actions locally, exactly as a dispatched request would. */
|
|
28
|
+
execute(actionId: string, params?: Record<string, unknown>): Promise<OUIActionResult>;
|
|
29
|
+
}
|
|
20
30
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* After an action handler executes, if the action has a polling config, the
|
|
26
|
-
* hook starts a polling loop that pushes observation updates until the
|
|
27
|
-
* operation completes or times out.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* ```tsx
|
|
31
|
-
* function DataVizPage() {
|
|
32
|
-
* const { state, updateState, goToStep } = useDataVizWizard();
|
|
33
|
-
*
|
|
34
|
-
* useSurface({
|
|
35
|
-
* surface: datavizSurface,
|
|
36
|
-
* context: { state, updateState, goToStep },
|
|
37
|
-
* send: agentTransport.send,
|
|
38
|
-
* active: true,
|
|
39
|
-
* });
|
|
40
|
-
*
|
|
41
|
-
* return <DataVizWizard />;
|
|
42
|
-
* }
|
|
43
|
-
* ```
|
|
31
|
+
* Mount a surface into the client's surface runtime for as long as the
|
|
32
|
+
* component is mounted (and `active`). The runtime answers dispatched requests
|
|
33
|
+
* for it, so the component needs no listener of its own.
|
|
44
34
|
*/
|
|
45
|
-
declare function useSurface<TContext>(options: UseSurfaceOptions<TContext>):
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
manifest: OUISurface;
|
|
49
|
-
/** Manually stop polling for a specific action */
|
|
50
|
-
stopPolling: (actionId: string) => void;
|
|
51
|
-
/** Stop all active pollers */
|
|
52
|
-
stopAllPolling: () => void;
|
|
53
|
-
};
|
|
35
|
+
declare function useSurface<TContext>(options: UseSurfaceOptions<TContext>): UseSurfaceResult;
|
|
36
|
+
/** Keep an observation on a mounted surface equal to `value`. */
|
|
37
|
+
declare function useObservation(surface: Pick<UseSurfaceResult, "pushObservation">, observationId: string, value: unknown): void;
|
|
54
38
|
/**
|
|
55
|
-
*
|
|
39
|
+
* Keep the UI unsettled while `busy` is true: an action's result waits for it.
|
|
40
|
+
* For work mounting cannot show, such as a route's code or a page's data still
|
|
41
|
+
* loading.
|
|
56
42
|
*/
|
|
57
|
-
declare function
|
|
58
|
-
type: string;
|
|
59
|
-
payload: unknown;
|
|
60
|
-
}) => void): void;
|
|
43
|
+
declare function useSurfaceHold(busy: boolean): void;
|
|
61
44
|
|
|
62
|
-
export { type UseSurfaceOptions, useObservation, useSurface };
|
|
45
|
+
export { SurfaceRuntimeProvider, type SurfaceRuntimeProviderProps, type UseSurfaceOptions, type UseSurfaceResult, useObservation, useSurface, useSurfaceHold, useSurfaceRuntime };
|
package/dist/react/index.js
CHANGED
package/dist/spec/index.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkZKM4XWAB_cjs = require('../chunk-ZKM4XWAB.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "OUI_PROTOCOL_EVENTS", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkZKM4XWAB_cjs.OUI_PROTOCOL_EVENTS; }
|
|
10
10
|
});
|
|
11
11
|
//# sourceMappingURL=index.cjs.map
|
|
12
12
|
//# sourceMappingURL=index.cjs.map
|
package/dist/spec/index.d.cts
CHANGED
|
@@ -127,7 +127,7 @@ interface OUIObservation {
|
|
|
127
127
|
/** JSON Schema for the observation's value */
|
|
128
128
|
schema: JSONSchema;
|
|
129
129
|
/** How frequently this observation updates */
|
|
130
|
-
updateFrequency?:
|
|
130
|
+
updateFrequency?: "realtime" | "on-change" | "polling";
|
|
131
131
|
}
|
|
132
132
|
/**
|
|
133
133
|
* Activation conditions — when a surface is available to the agent.
|
|
@@ -184,6 +184,34 @@ interface OUIActionResult {
|
|
|
184
184
|
durationMs?: number;
|
|
185
185
|
/** Timestamp of the result */
|
|
186
186
|
timestamp: number;
|
|
187
|
+
/**
|
|
188
|
+
* The surfaces active on the client once the action's effects settled.
|
|
189
|
+
*
|
|
190
|
+
* An action can change what the agent is able to do next: navigating
|
|
191
|
+
* unmounts one page's surfaces and mounts another's. Without this, the agent
|
|
192
|
+
* would act on the capability set it had before the action, which is the
|
|
193
|
+
* set the action just replaced.
|
|
194
|
+
*/
|
|
195
|
+
surfaces?: OUISurface[];
|
|
196
|
+
/** Latest observation values per surface once the action's effects settled. */
|
|
197
|
+
observations?: OUIObservationSnapshot;
|
|
198
|
+
/**
|
|
199
|
+
* False when the client's deadline passed before its UI settled, so
|
|
200
|
+
* `surfaces` and `observations` may still be changing. Absent or true
|
|
201
|
+
* otherwise.
|
|
202
|
+
*/
|
|
203
|
+
settled?: boolean;
|
|
204
|
+
}
|
|
205
|
+
/** Latest observation values, keyed by surface id and then observation id. */
|
|
206
|
+
type OUIObservationSnapshot = Record<string, Record<string, unknown>>;
|
|
207
|
+
/**
|
|
208
|
+
* What a client can do right now: the surfaces it has mounted and their latest
|
|
209
|
+
* observation values. A client sends this to its agent runtime (for example,
|
|
210
|
+
* with each turn), and returns it on every action result.
|
|
211
|
+
*/
|
|
212
|
+
interface OUISurfaceSnapshot {
|
|
213
|
+
surfaces: OUISurface[];
|
|
214
|
+
observations: OUIObservationSnapshot;
|
|
187
215
|
}
|
|
188
216
|
/**
|
|
189
217
|
* An observation update pushed from the surface to the agent.
|
|
@@ -220,19 +248,19 @@ interface OUISurfaceDeregistration {
|
|
|
220
248
|
* All protocol events exchanged between agent runtime and surfaces.
|
|
221
249
|
*/
|
|
222
250
|
type OUIProtocolEvent = {
|
|
223
|
-
type:
|
|
251
|
+
type: "surface:register";
|
|
224
252
|
payload: OUISurfaceRegistration;
|
|
225
253
|
} | {
|
|
226
|
-
type:
|
|
254
|
+
type: "surface:deregister";
|
|
227
255
|
payload: OUISurfaceDeregistration;
|
|
228
256
|
} | {
|
|
229
|
-
type:
|
|
257
|
+
type: "action:request";
|
|
230
258
|
payload: OUIActionRequest;
|
|
231
259
|
} | {
|
|
232
|
-
type:
|
|
260
|
+
type: "action:result";
|
|
233
261
|
payload: OUIActionResult;
|
|
234
262
|
} | {
|
|
235
|
-
type:
|
|
263
|
+
type: "observation:update";
|
|
236
264
|
payload: OUIObservationUpdate;
|
|
237
265
|
};
|
|
238
266
|
/**
|
|
@@ -246,4 +274,4 @@ declare const OUI_PROTOCOL_EVENTS: {
|
|
|
246
274
|
readonly OBSERVATION_UPDATE: "observation:update";
|
|
247
275
|
};
|
|
248
276
|
|
|
249
|
-
export { type JSONSchema, type OUIAction, type OUIActionPolling, type OUIActionRequest, type OUIActionResult, type OUIActivation, type OUIObservation, type OUIObservationUpdate, type OUIProtocolEvent, type OUISurface, type OUISurfaceDeregistration, type OUISurfaceRegistration, OUI_PROTOCOL_EVENTS };
|
|
277
|
+
export { type JSONSchema, type OUIAction, type OUIActionPolling, type OUIActionRequest, type OUIActionResult, type OUIActivation, type OUIObservation, type OUIObservationSnapshot, type OUIObservationUpdate, type OUIProtocolEvent, type OUISurface, type OUISurfaceDeregistration, type OUISurfaceRegistration, type OUISurfaceSnapshot, OUI_PROTOCOL_EVENTS };
|
package/dist/spec/index.d.ts
CHANGED
|
@@ -127,7 +127,7 @@ interface OUIObservation {
|
|
|
127
127
|
/** JSON Schema for the observation's value */
|
|
128
128
|
schema: JSONSchema;
|
|
129
129
|
/** How frequently this observation updates */
|
|
130
|
-
updateFrequency?:
|
|
130
|
+
updateFrequency?: "realtime" | "on-change" | "polling";
|
|
131
131
|
}
|
|
132
132
|
/**
|
|
133
133
|
* Activation conditions — when a surface is available to the agent.
|
|
@@ -184,6 +184,34 @@ interface OUIActionResult {
|
|
|
184
184
|
durationMs?: number;
|
|
185
185
|
/** Timestamp of the result */
|
|
186
186
|
timestamp: number;
|
|
187
|
+
/**
|
|
188
|
+
* The surfaces active on the client once the action's effects settled.
|
|
189
|
+
*
|
|
190
|
+
* An action can change what the agent is able to do next: navigating
|
|
191
|
+
* unmounts one page's surfaces and mounts another's. Without this, the agent
|
|
192
|
+
* would act on the capability set it had before the action, which is the
|
|
193
|
+
* set the action just replaced.
|
|
194
|
+
*/
|
|
195
|
+
surfaces?: OUISurface[];
|
|
196
|
+
/** Latest observation values per surface once the action's effects settled. */
|
|
197
|
+
observations?: OUIObservationSnapshot;
|
|
198
|
+
/**
|
|
199
|
+
* False when the client's deadline passed before its UI settled, so
|
|
200
|
+
* `surfaces` and `observations` may still be changing. Absent or true
|
|
201
|
+
* otherwise.
|
|
202
|
+
*/
|
|
203
|
+
settled?: boolean;
|
|
204
|
+
}
|
|
205
|
+
/** Latest observation values, keyed by surface id and then observation id. */
|
|
206
|
+
type OUIObservationSnapshot = Record<string, Record<string, unknown>>;
|
|
207
|
+
/**
|
|
208
|
+
* What a client can do right now: the surfaces it has mounted and their latest
|
|
209
|
+
* observation values. A client sends this to its agent runtime (for example,
|
|
210
|
+
* with each turn), and returns it on every action result.
|
|
211
|
+
*/
|
|
212
|
+
interface OUISurfaceSnapshot {
|
|
213
|
+
surfaces: OUISurface[];
|
|
214
|
+
observations: OUIObservationSnapshot;
|
|
187
215
|
}
|
|
188
216
|
/**
|
|
189
217
|
* An observation update pushed from the surface to the agent.
|
|
@@ -220,19 +248,19 @@ interface OUISurfaceDeregistration {
|
|
|
220
248
|
* All protocol events exchanged between agent runtime and surfaces.
|
|
221
249
|
*/
|
|
222
250
|
type OUIProtocolEvent = {
|
|
223
|
-
type:
|
|
251
|
+
type: "surface:register";
|
|
224
252
|
payload: OUISurfaceRegistration;
|
|
225
253
|
} | {
|
|
226
|
-
type:
|
|
254
|
+
type: "surface:deregister";
|
|
227
255
|
payload: OUISurfaceDeregistration;
|
|
228
256
|
} | {
|
|
229
|
-
type:
|
|
257
|
+
type: "action:request";
|
|
230
258
|
payload: OUIActionRequest;
|
|
231
259
|
} | {
|
|
232
|
-
type:
|
|
260
|
+
type: "action:result";
|
|
233
261
|
payload: OUIActionResult;
|
|
234
262
|
} | {
|
|
235
|
-
type:
|
|
263
|
+
type: "observation:update";
|
|
236
264
|
payload: OUIObservationUpdate;
|
|
237
265
|
};
|
|
238
266
|
/**
|
|
@@ -246,4 +274,4 @@ declare const OUI_PROTOCOL_EVENTS: {
|
|
|
246
274
|
readonly OBSERVATION_UPDATE: "observation:update";
|
|
247
275
|
};
|
|
248
276
|
|
|
249
|
-
export { type JSONSchema, type OUIAction, type OUIActionPolling, type OUIActionRequest, type OUIActionResult, type OUIActivation, type OUIObservation, type OUIObservationUpdate, type OUIProtocolEvent, type OUISurface, type OUISurfaceDeregistration, type OUISurfaceRegistration, OUI_PROTOCOL_EVENTS };
|
|
277
|
+
export { type JSONSchema, type OUIAction, type OUIActionPolling, type OUIActionRequest, type OUIActionResult, type OUIActivation, type OUIObservation, type OUIObservationSnapshot, type OUIObservationUpdate, type OUIProtocolEvent, type OUISurface, type OUISurfaceDeregistration, type OUISurfaceRegistration, type OUISurfaceSnapshot, OUI_PROTOCOL_EVENTS };
|
package/dist/spec/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { JSONSchema, OUIActionPolling, OUIActivation, OUISurface } from './spec/index.cjs';
|
|
1
|
+
import { JSONSchema, OUIActionPolling, OUIActivation, OUISurface, OUISurfaceSnapshot, OUIActionRequest, OUIActionResult } from './spec/index.cjs';
|
|
2
|
+
import { S as SocketLike, d as OUITransportConfig } from './websocket-YfWILdZ4.cjs';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Nominal branding for values OUI must construct itself.
|
|
@@ -148,4 +149,103 @@ interface DefinedSurface<TContext = unknown> extends SurfaceDefinition<TContext>
|
|
|
148
149
|
getPollingConfig(actionId: string): OUIActionPolling | undefined;
|
|
149
150
|
}
|
|
150
151
|
|
|
151
|
-
|
|
152
|
+
/**
|
|
153
|
+
* The client-side surface runtime.
|
|
154
|
+
*
|
|
155
|
+
* Holds the surfaces a client has mounted, answers every action request with a
|
|
156
|
+
* result, and produces the snapshot an agent runtime works from.
|
|
157
|
+
*
|
|
158
|
+
* WHY THIS EXISTS
|
|
159
|
+
*
|
|
160
|
+
* The first integration kept no client-side record of what was mounted. Each
|
|
161
|
+
* surface hook registered itself with a server-side registry and listened for
|
|
162
|
+
* dispatches on its own. Three things followed:
|
|
163
|
+
*
|
|
164
|
+
* - The registry was the only record of what the client could do, and it lost
|
|
165
|
+
* entries: a dead socket's cleanup removed a live tab's registration, and the
|
|
166
|
+
* browser never registered again. The agent then had no UI tools at all.
|
|
167
|
+
* - Nothing answered a dispatch. The agent was told an action succeeded before
|
|
168
|
+
* the client had run it, and never saw the page an action led to.
|
|
169
|
+
* - Every hook listened independently, through two paths, so one dispatch ran
|
|
170
|
+
* twice and nothing de-duplicated it.
|
|
171
|
+
*
|
|
172
|
+
* Here the client is the record. `snapshot()` is what the client can do right
|
|
173
|
+
* now, and every request is run once, waited on until the UI settles, and
|
|
174
|
+
* answered with its result and the snapshot after it.
|
|
175
|
+
*/
|
|
176
|
+
|
|
177
|
+
interface SettleOptions {
|
|
178
|
+
/**
|
|
179
|
+
* The UI counts as settled once nothing has mounted, unmounted or changed an
|
|
180
|
+
* observation for this long, and no hold is open. Default 250 ms.
|
|
181
|
+
*/
|
|
182
|
+
quietMs?: number;
|
|
183
|
+
/** Give up waiting after this long and answer with `settled: false`. Default 5000 ms. */
|
|
184
|
+
timeoutMs?: number;
|
|
185
|
+
}
|
|
186
|
+
interface SurfaceRuntimeOptions {
|
|
187
|
+
/** The socket to answer requests on. Can be set or replaced later with `attach`. */
|
|
188
|
+
socket?: SocketLike | null;
|
|
189
|
+
/** Wire configuration for the transport the runtime builds on the socket. */
|
|
190
|
+
transport?: OUITransportConfig;
|
|
191
|
+
/**
|
|
192
|
+
* Also announce registrations and observations over the transport, for agent
|
|
193
|
+
* runtimes that keep a server-side registry. Default true.
|
|
194
|
+
*
|
|
195
|
+
* An agent runtime that takes the client's snapshot instead (sent with each
|
|
196
|
+
* turn, and returned on every result) has no use for them: set false.
|
|
197
|
+
*/
|
|
198
|
+
announce?: boolean;
|
|
199
|
+
settle?: SettleOptions;
|
|
200
|
+
/** How many answered request ids to remember, for de-duplication. Default 500. */
|
|
201
|
+
dedupeWindow?: number;
|
|
202
|
+
/**
|
|
203
|
+
* Decides whether a request that arrived on the socket may run at all. A
|
|
204
|
+
* refused request is neither run nor answered, and is logged.
|
|
205
|
+
*
|
|
206
|
+
* The server should be the only sender of action requests, but a client can
|
|
207
|
+
* also check that a request is one it expects: for example, only while its
|
|
208
|
+
* agent has a turn in progress. Requests passed to `execute` directly are
|
|
209
|
+
* not checked; they come from the application itself.
|
|
210
|
+
*/
|
|
211
|
+
accept?: (request: OUIActionRequest) => boolean;
|
|
212
|
+
}
|
|
213
|
+
interface MountedSurface {
|
|
214
|
+
readonly surfaceId: string;
|
|
215
|
+
/** Record an observation value. A no-op once unmounted. */
|
|
216
|
+
pushObservation(observationId: string, value: unknown): void;
|
|
217
|
+
/** Remove this mount. Other mounts of the same surface id are unaffected. */
|
|
218
|
+
unmount(): void;
|
|
219
|
+
}
|
|
220
|
+
interface SurfaceRuntime {
|
|
221
|
+
/**
|
|
222
|
+
* Mount a surface. `getContext` is read when an action runs, so handlers see
|
|
223
|
+
* the latest state rather than the state at mount time.
|
|
224
|
+
*
|
|
225
|
+
* Mounting the same surface id twice is allowed (React StrictMode does it on
|
|
226
|
+
* every mount); the most recent mount serves its actions.
|
|
227
|
+
*/
|
|
228
|
+
mount<TContext>(surface: DefinedSurface<TContext>, getContext: () => TContext): MountedSurface;
|
|
229
|
+
/** Answer requests arriving on this socket (null detaches). */
|
|
230
|
+
attach(socket: SocketLike | null): void;
|
|
231
|
+
/** What the client can do right now. */
|
|
232
|
+
snapshot(): OUISurfaceSnapshot;
|
|
233
|
+
/**
|
|
234
|
+
* Run a request once and resolve with its result. A request id seen before
|
|
235
|
+
* resolves with the first result instead of running again.
|
|
236
|
+
*/
|
|
237
|
+
execute(request: OUIActionRequest): Promise<OUIActionResult>;
|
|
238
|
+
/**
|
|
239
|
+
* Keep the UI unsettled until the returned function is called. For work an
|
|
240
|
+
* action starts that mounting and unmounting cannot show, such as a route's
|
|
241
|
+
* code still loading or a page fetching the data it will display.
|
|
242
|
+
*/
|
|
243
|
+
hold(): () => void;
|
|
244
|
+
/** Called whenever the snapshot changes. */
|
|
245
|
+
subscribe(listener: () => void): () => void;
|
|
246
|
+
/** Stop polling, detach from the socket and forget every mount. */
|
|
247
|
+
dispose(): void;
|
|
248
|
+
}
|
|
249
|
+
declare function createSurfaceRuntime(options?: SurfaceRuntimeOptions): SurfaceRuntime;
|
|
250
|
+
|
|
251
|
+
export { type ActionDefinition as A, type DefinedSurface as D, type MountedSurface as M, type OUIBranded as O, type SettleOptions as S, type ActionHandlerResult as a, type ActionPollingConfig as b, type ObservationDefinition as c, type SurfaceDefinition as d, type SurfaceRuntime as e, type SurfaceRuntimeOptions as f, createSurfaceRuntime as g, defineSurface as h };
|