@webskill/sdk 0.3.0 → 0.5.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/dist/agent.d.ts +2 -0
- package/dist/agent.js +867 -0
- package/dist/browser.d.ts +137 -4
- package/dist/browser.js +458 -22
- package/dist/{catalogComponents-C_V39rbF-BOHveMWa.js → catalogComponents-DV7cPpUm-C77AEEx9.js} +477 -157
- package/dist/{dist-rorEJsNi.js → dist-6C03DShK.js} +654 -298
- package/dist/{dist-ZKaM8j06.js → dist-bewtXYlO.js} +1061 -807
- package/dist/governance.d.ts +87 -10
- package/dist/governance.js +194 -24
- package/dist/{index-wiV5X8Rz.d.ts → index-Bsqg4ftU.d.ts} +151 -143
- package/dist/index-D_7ZZjkl.d.ts +411 -0
- package/dist/{index-8d-oEDww.d.ts → index-vBz_FC9w.d.ts} +289 -24
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -2
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +1 -1
- package/dist/memoryArtifactStore-BtOeB_hm-tj3fC5ip.js +78 -0
- package/dist/node.d.ts +8 -4
- package/dist/node.js +1 -1
- package/dist/{openUiLibrary-B8-Cvou9-BbpNTXS3.js → openUiLibrary-W3Ce896k-ClFTRZFs.js} +6 -5
- package/dist/{skillVersionStore-DOEI9ptb-BxbYL70B.d.ts → skillVersionStore-BzLbzFOL-CxwIewHJ.d.ts} +43 -11
- package/dist/{testing-CsrG3XLz.js → testing-DDCJWvgA.js} +7 -5
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +2 -2
- package/dist/{types-AmKCKJn_-VGabeXK4.d.ts → types-D_hoCri8-BnNPiZCi.d.ts} +111 -72
- package/dist/ui-react.d.ts +352 -20
- package/dist/ui-react.js +3804 -3478
- package/dist/ui-vue.d.ts +1 -1
- package/dist/ui-vue.js +25 -6
- package/dist/ui.d.ts +4 -3
- package/dist/ui.js +3 -3
- package/dist/{webskillLitCatalog-CNaUpasU-BslMcxRZ.js → webskillLitCatalog-_mugzRHx-DiuJpCuf.js} +398 -122
- package/package.json +6 -1
- package/dist/jsonRenderRegistry-9GrWP_hE-U6Do3Kid.js +0 -2468
- package/dist/memoryArtifactStore-C9lFVqPF-yFz6yJj0.js +0 -48
package/dist/ui-react.d.ts
CHANGED
|
@@ -1,20 +1,279 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
import {
|
|
1
|
+
import { C as UiSpecEvent, D as UiSurfaceActionResponse, E as UiSurfaceActionRequest, S as UiSpecDrafts, T as UiSpecSnapshot, b as UiBridge, c as InteractionResponse, mt as UiSpecNode, s as InteractionRequest, x as UiSpecActionCapability, y as RenderResultRequest } from "./types-D_hoCri8-BnNPiZCi.js";
|
|
2
|
+
import { b as InteractionSpecLabels } from "./index-Bsqg4ftU.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { ComponentType, ReactNode } from "react";
|
|
5
|
+
import "react/jsx-runtime";
|
|
6
|
+
//#region ../../node_modules/.pnpm/@json-render+core@0.19.0_zod@4.4.3/node_modules/@json-render/core/dist/store-utils-D98Czbil.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Confirmation dialog configuration
|
|
9
|
+
*/
|
|
10
|
+
interface ActionConfirm {
|
|
11
|
+
title: string;
|
|
12
|
+
message: string;
|
|
13
|
+
confirmLabel?: string;
|
|
14
|
+
cancelLabel?: string;
|
|
15
|
+
variant?: "default" | "danger";
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Action success handler
|
|
19
|
+
*/
|
|
20
|
+
type ActionOnSuccess = {
|
|
21
|
+
navigate: string;
|
|
22
|
+
} | {
|
|
23
|
+
set: Record<string, unknown>;
|
|
24
|
+
} | {
|
|
25
|
+
action: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Action error handler
|
|
29
|
+
*/
|
|
30
|
+
type ActionOnError = {
|
|
31
|
+
set: Record<string, unknown>;
|
|
32
|
+
} | {
|
|
33
|
+
action: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Action binding — maps an event to an action invocation.
|
|
37
|
+
*
|
|
38
|
+
* Used inside the `on` field of a UIElement:
|
|
39
|
+
* ```json
|
|
40
|
+
* { "on": { "press": { "action": "setState", "params": { "statePath": "/x", "value": 1 } } } }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
interface ActionBinding {
|
|
44
|
+
/** Action name (must be in catalog) */
|
|
45
|
+
action: string;
|
|
46
|
+
/** Parameters to pass to the action handler */
|
|
47
|
+
params?: Record<string, DynamicValue>;
|
|
48
|
+
/** Confirmation dialog before execution */
|
|
49
|
+
confirm?: ActionConfirm;
|
|
50
|
+
/** Handler after successful execution */
|
|
51
|
+
onSuccess?: ActionOnSuccess;
|
|
52
|
+
/** Handler after failed execution */
|
|
53
|
+
onError?: ActionOnError;
|
|
54
|
+
/** Whether to prevent default browser behavior (e.g. navigation on links) */
|
|
55
|
+
preventDefault?: boolean;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Dynamic value - can be a literal or a `{ $state }` reference to the state model.
|
|
59
|
+
*
|
|
60
|
+
* Used in action params and validation args where values can either be
|
|
61
|
+
* hardcoded or resolved from state at runtime.
|
|
62
|
+
*/
|
|
63
|
+
type DynamicValue<T = unknown> = T | {
|
|
64
|
+
$state: string;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Base UI element structure for v2
|
|
68
|
+
*/
|
|
69
|
+
interface UIElement<T extends string = string, P = Record<string, unknown>> {
|
|
70
|
+
/** Component type from the catalog */
|
|
71
|
+
type: T;
|
|
72
|
+
/** Component props */
|
|
73
|
+
props: P;
|
|
74
|
+
/** Child element keys (flat structure) */
|
|
75
|
+
children?: string[];
|
|
76
|
+
/** Visibility condition */
|
|
77
|
+
visible?: VisibilityCondition;
|
|
78
|
+
/** Event bindings — maps event names to action bindings */
|
|
79
|
+
on?: Record<string, ActionBinding | ActionBinding[]>;
|
|
80
|
+
/** Repeat children once per item in a state array */
|
|
81
|
+
repeat?: {
|
|
82
|
+
statePath: string;
|
|
83
|
+
key?: string;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* State watchers — maps JSON Pointer state paths to action bindings.
|
|
87
|
+
* When the value at a watched path changes, the bound actions fire.
|
|
88
|
+
* Useful for cascading dependencies (e.g. country → city option loading).
|
|
89
|
+
*/
|
|
90
|
+
watch?: Record<string, ActionBinding | ActionBinding[]>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Shared comparison operators for visibility conditions.
|
|
94
|
+
*
|
|
95
|
+
* Use at most ONE comparison operator per condition. If multiple are
|
|
96
|
+
* provided, only the first matching one is evaluated (precedence:
|
|
97
|
+
* eq > neq > gt > gte > lt > lte). With no operator, truthiness is checked.
|
|
98
|
+
*
|
|
99
|
+
* `not` inverts the final result of whichever operator (or truthiness
|
|
100
|
+
* check) is used.
|
|
101
|
+
*/
|
|
102
|
+
type ComparisonOperators = {
|
|
103
|
+
eq?: unknown;
|
|
104
|
+
neq?: unknown;
|
|
105
|
+
gt?: number | {
|
|
106
|
+
$state: string;
|
|
107
|
+
};
|
|
108
|
+
gte?: number | {
|
|
109
|
+
$state: string;
|
|
110
|
+
};
|
|
111
|
+
lt?: number | {
|
|
112
|
+
$state: string;
|
|
113
|
+
};
|
|
114
|
+
lte?: number | {
|
|
115
|
+
$state: string;
|
|
116
|
+
};
|
|
117
|
+
not?: true;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* A single state-based condition.
|
|
121
|
+
* Resolves `$state` to a value from the state model, then applies the operator.
|
|
122
|
+
* Without an operator, checks truthiness.
|
|
123
|
+
*
|
|
124
|
+
* When `not` is `true`, the result of the entire condition is inverted.
|
|
125
|
+
* For example `{ $state: "/count", gt: 5, not: true }` means "NOT greater than 5".
|
|
126
|
+
*/
|
|
127
|
+
type StateCondition = {
|
|
128
|
+
$state: string;
|
|
129
|
+
} & ComparisonOperators;
|
|
130
|
+
/**
|
|
131
|
+
* A condition that resolves `$item` to a field on the current repeat item.
|
|
132
|
+
* Only meaningful inside a `repeat` scope.
|
|
133
|
+
*
|
|
134
|
+
* Use `""` to reference the whole item, or `"field"` for a specific field.
|
|
135
|
+
*/
|
|
136
|
+
type ItemCondition = {
|
|
137
|
+
$item: string;
|
|
138
|
+
} & ComparisonOperators;
|
|
139
|
+
/**
|
|
140
|
+
* A condition that resolves `$index` to the current repeat array index.
|
|
141
|
+
* Only meaningful inside a `repeat` scope.
|
|
142
|
+
*/
|
|
143
|
+
type IndexCondition = {
|
|
144
|
+
$index: true;
|
|
145
|
+
} & ComparisonOperators;
|
|
146
|
+
/** A single visibility condition (state, item, or index). */
|
|
147
|
+
type SingleCondition = StateCondition | ItemCondition | IndexCondition;
|
|
148
|
+
/**
|
|
149
|
+
* AND wrapper — all child conditions must be true.
|
|
150
|
+
* This is the explicit form of the implicit array AND (`SingleCondition[]`).
|
|
151
|
+
* Unlike the implicit form, `$and` supports nested `$or` and `$and` conditions.
|
|
152
|
+
*/
|
|
153
|
+
type AndCondition = {
|
|
154
|
+
$and: VisibilityCondition[];
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* OR wrapper — at least one child condition must be true.
|
|
158
|
+
*/
|
|
159
|
+
type OrCondition = {
|
|
160
|
+
$or: VisibilityCondition[];
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Visibility condition types.
|
|
164
|
+
* - `boolean` — always/never
|
|
165
|
+
* - `SingleCondition` — single condition (`$state`, `$item`, or `$index`)
|
|
166
|
+
* - `SingleCondition[]` — implicit AND (all must be true)
|
|
167
|
+
* - `AndCondition` — `{ $and: [...] }`, explicit AND (all must be true)
|
|
168
|
+
* - `OrCondition` — `{ $or: [...] }`, at least one must be true
|
|
169
|
+
*/
|
|
170
|
+
type VisibilityCondition = boolean | SingleCondition | SingleCondition[] | AndCondition | OrCondition;
|
|
171
|
+
/**
|
|
172
|
+
* State model type
|
|
173
|
+
*/
|
|
174
|
+
type StateModel = Record<string, unknown>;
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region ../../node_modules/.pnpm/@json-render+react@0.19.0_react@19.2.8_zod@4.4.3/node_modules/@json-render/react/dist/index.d.ts
|
|
177
|
+
/**
|
|
178
|
+
* State setter function for updating application state
|
|
179
|
+
*/
|
|
180
|
+
type SetState = (updater: (prev: Record<string, unknown>) => Record<string, unknown>) => void;
|
|
181
|
+
/**
|
|
182
|
+
* Handle returned by the `on()` function for a specific event.
|
|
183
|
+
* Provides metadata about the event binding and a method to fire it.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```ts
|
|
187
|
+
* const press = on("press");
|
|
188
|
+
* if (press.shouldPreventDefault) e.preventDefault();
|
|
189
|
+
* press.emit();
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
interface EventHandle {
|
|
193
|
+
/** Fire the event (resolve action bindings) */
|
|
194
|
+
emit: () => void;
|
|
195
|
+
/** Whether any binding requested preventDefault */
|
|
196
|
+
shouldPreventDefault: boolean;
|
|
197
|
+
/** Whether any handler is bound to this event */
|
|
198
|
+
bound: boolean;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Props passed to component renderers
|
|
202
|
+
*/
|
|
203
|
+
interface ComponentRenderProps<P = Record<string, unknown>> {
|
|
204
|
+
/** The element being rendered */
|
|
205
|
+
element: UIElement<string, P>;
|
|
206
|
+
/** Rendered children */
|
|
207
|
+
children?: ReactNode;
|
|
208
|
+
/** Emit a named event. The renderer resolves the event to action binding(s) from the element's `on` field. Always provided by the renderer. */
|
|
209
|
+
emit: (event: string) => void;
|
|
210
|
+
/** Get an event handle with metadata (shouldPreventDefault, bound). Use when you need to inspect event bindings. */
|
|
211
|
+
on: (event: string) => EventHandle;
|
|
212
|
+
/**
|
|
213
|
+
* Two-way binding paths resolved from `$bindState` / `$bindItem` expressions.
|
|
214
|
+
* Maps prop name → absolute state path for write-back.
|
|
215
|
+
* Only present when at least one prop uses `{ $bindState: "..." }` or `{ $bindItem: "..." }`.
|
|
216
|
+
*/
|
|
217
|
+
bindings?: Record<string, string>;
|
|
218
|
+
/** Whether the parent is loading */
|
|
219
|
+
loading?: boolean;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Component renderer type
|
|
223
|
+
*/
|
|
224
|
+
type ComponentRenderer<P = Record<string, unknown>> = ComponentType<ComponentRenderProps<P>>;
|
|
225
|
+
/**
|
|
226
|
+
* Registry of component renderers
|
|
227
|
+
*/
|
|
228
|
+
type ComponentRegistry = Record<string, ComponentRenderer<any>>;
|
|
229
|
+
/**
|
|
230
|
+
* Result returned by defineRegistry
|
|
231
|
+
*/
|
|
232
|
+
interface DefineRegistryResult {
|
|
233
|
+
/** Component registry for `<Renderer registry={...} />` */
|
|
234
|
+
registry: ComponentRegistry;
|
|
235
|
+
/**
|
|
236
|
+
* Create ActionProvider-compatible handlers.
|
|
237
|
+
* Accepts getter functions so handlers always read the latest state/setState
|
|
238
|
+
* (e.g. from React refs).
|
|
239
|
+
*/
|
|
240
|
+
handlers: (getSetState: () => SetState | undefined, getState: () => StateModel) => Record<string, (params: Record<string, unknown>) => Promise<void>>;
|
|
241
|
+
/**
|
|
242
|
+
* Execute an action by name imperatively
|
|
243
|
+
* (for use outside the React tree, e.g. initial state loading).
|
|
244
|
+
*/
|
|
245
|
+
executeAction: (actionName: string, params: Record<string, unknown> | undefined, setState: SetState, state?: StateModel) => Promise<void>;
|
|
246
|
+
}
|
|
247
|
+
//#endregion
|
|
5
248
|
//#region ../ui-react/dist/index.d.ts
|
|
6
249
|
//#region src/surfaceStore.d.ts
|
|
7
250
|
/** Observable, revision-checked snapshot store for framework-neutral UI surfaces. @experimental */
|
|
8
251
|
declare class UiSurfaceStore {
|
|
9
252
|
#private;
|
|
10
253
|
subscribe: (listener: () => void) => (() => void);
|
|
11
|
-
get snapshots(): readonly
|
|
12
|
-
apply(event:
|
|
254
|
+
get snapshots(): readonly UiSpecSnapshot[];
|
|
255
|
+
apply(event: UiSpecEvent): void;
|
|
13
256
|
}
|
|
14
257
|
//#endregion
|
|
15
258
|
//#region src/bridgeState.d.ts
|
|
259
|
+
/**
|
|
260
|
+
* 一次被丢弃的 surface action(FR-11.7)。
|
|
261
|
+
*
|
|
262
|
+
* 丢弃本身是对的(重放/串扰防护),但静默丢弃会让「点了没反应」变成无从排查的现象。
|
|
263
|
+
* @experimental
|
|
264
|
+
*/
|
|
265
|
+
interface DroppedSurfaceActionWarning {
|
|
266
|
+
/** duplicate:nonce 已被消费;no-pending:当前没有等待中的动作;mismatch:与待决动作不是同一个 */
|
|
267
|
+
reason: 'duplicate' | 'no-pending' | 'mismatch';
|
|
268
|
+
nonce: string;
|
|
269
|
+
message: string;
|
|
270
|
+
/** 丢弃发生时的待决状态,用于定位串扰 */
|
|
271
|
+
pending: UiSurfaceActionRequest | null;
|
|
272
|
+
}
|
|
16
273
|
interface ReactBridgeStateOptions {
|
|
17
274
|
onSurfaceDraftChange?(runId: string, surfaceId: string, value: Record<string, unknown>): Promise<void> | void;
|
|
275
|
+
/** 覆盖默认的 console.warn 上报(测试与宿主遥测用)。@experimental */
|
|
276
|
+
onDroppedSurfaceAction?(warning: DroppedSurfaceActionWarning): void;
|
|
18
277
|
}
|
|
19
278
|
/**
|
|
20
279
|
* React 桥接状态:UiBridge 实现 + useSyncExternalStore 兼容订阅。
|
|
@@ -30,9 +289,9 @@ declare class ReactBridgeState implements UiBridge {
|
|
|
30
289
|
streamingRunId: string | null;
|
|
31
290
|
streamingText: string;
|
|
32
291
|
constructor(options?: ReactBridgeStateOptions);
|
|
33
|
-
get surfaceSnapshots(): readonly
|
|
34
|
-
surfaceDrafts(runId: string):
|
|
35
|
-
restoreSurfaceDrafts(runId: string, drafts:
|
|
292
|
+
get surfaceSnapshots(): readonly UiSpecSnapshot[];
|
|
293
|
+
surfaceDrafts(runId: string): UiSpecDrafts;
|
|
294
|
+
restoreSurfaceDrafts(runId: string, drafts: UiSpecDrafts | undefined): void;
|
|
36
295
|
setSurfaceDraft(runId: string, surfaceId: string, value: Record<string, unknown>): void;
|
|
37
296
|
/** React useSyncExternalStore 兼容订阅 */
|
|
38
297
|
subscribe: (listener: () => void) => (() => void);
|
|
@@ -42,9 +301,12 @@ declare class ReactBridgeState implements UiBridge {
|
|
|
42
301
|
/** runtime 交互超时/取消:卸载表单并以 cancelled resolve pending Promise(防悬挂 + 残留) */
|
|
43
302
|
cancel(id: string): void;
|
|
44
303
|
renderResult(input: RenderResultRequest): Promise<void>;
|
|
45
|
-
renderSurface(event:
|
|
304
|
+
renderSurface(event: UiSpecEvent): Promise<void>;
|
|
46
305
|
requestSurfaceAction(input: UiSurfaceActionRequest): Promise<UiSurfaceActionResponse>;
|
|
47
|
-
/**
|
|
306
|
+
/**
|
|
307
|
+
* Resolves exactly one pending action capability; stale or duplicate nonces are ignored.
|
|
308
|
+
* Every ignored response is reported through `onDroppedSurfaceAction` (FR-11.7).
|
|
309
|
+
*/
|
|
48
310
|
resolveSurfaceAction(response: UiSurfaceActionResponse): boolean;
|
|
49
311
|
cancelSurfaceAction(nonce: string): void;
|
|
50
312
|
onTextDelta(runId: string, delta: string): Promise<void>;
|
|
@@ -72,14 +334,16 @@ declare function StreamingText({ bridge }: {
|
|
|
72
334
|
interface CustomSurfaceActionEvent {
|
|
73
335
|
surfaceId: string;
|
|
74
336
|
actionId: string;
|
|
75
|
-
intent:
|
|
337
|
+
intent: UiSpecActionCapability['intent'];
|
|
76
338
|
nonce?: string;
|
|
339
|
+
/** 提交动作所属的表单容器;一张 surface 只有一个表单时省略 */
|
|
340
|
+
scopeId?: string;
|
|
77
341
|
value?: Record<string, unknown>;
|
|
78
342
|
}
|
|
79
343
|
interface RegisteredSurfaceProps<Props> {
|
|
80
344
|
surfaceId: string;
|
|
81
345
|
props: Props;
|
|
82
|
-
actions: readonly
|
|
346
|
+
actions: readonly UiSpecActionCapability[];
|
|
83
347
|
onAction?(event: CustomSurfaceActionEvent): void;
|
|
84
348
|
}
|
|
85
349
|
interface SurfaceRegistration<Props> {
|
|
@@ -102,7 +366,7 @@ interface UiSurfaceActionEvent {
|
|
|
102
366
|
runId?: string;
|
|
103
367
|
surfaceId: string;
|
|
104
368
|
actionId: string;
|
|
105
|
-
intent:
|
|
369
|
+
intent: UiSpecActionCapability['intent'];
|
|
106
370
|
nonce?: string;
|
|
107
371
|
value?: Record<string, unknown>;
|
|
108
372
|
}
|
|
@@ -114,10 +378,10 @@ interface UiSurfaceListProps {
|
|
|
114
378
|
onAction?(event: UiSurfaceActionEvent): void;
|
|
115
379
|
}
|
|
116
380
|
interface UiSurfaceSnapshotListProps {
|
|
117
|
-
snapshots: readonly
|
|
381
|
+
snapshots: readonly UiSpecSnapshot[];
|
|
118
382
|
registry?: SurfaceRegistry;
|
|
119
383
|
onAction?(event: UiSurfaceActionEvent): void;
|
|
120
|
-
drafts?:
|
|
384
|
+
drafts?: UiSpecDrafts;
|
|
121
385
|
onDraftChange?(event: {
|
|
122
386
|
runId: string;
|
|
123
387
|
surfaceId: string;
|
|
@@ -135,35 +399,103 @@ declare const NATIVE_SPEC_COMPONENTS: readonly string[];
|
|
|
135
399
|
interface NativeSpecSurfaceProps {
|
|
136
400
|
surfaceId: string;
|
|
137
401
|
spec: UiSpecNode;
|
|
138
|
-
actions: readonly
|
|
402
|
+
actions: readonly UiSpecActionCapability[];
|
|
139
403
|
registry?: SurfaceRegistry;
|
|
404
|
+
/** 草稿归属的运行;缺省表示不持久化(历史回放) */
|
|
405
|
+
runId?: string;
|
|
406
|
+
draft?: Record<string, unknown>;
|
|
140
407
|
onAction?(event: CustomSurfaceActionEvent): void;
|
|
408
|
+
onDraftChange?(event: {
|
|
409
|
+
runId: string;
|
|
410
|
+
surfaceId: string;
|
|
411
|
+
value: Record<string, unknown>;
|
|
412
|
+
}): void;
|
|
141
413
|
}
|
|
142
414
|
/**
|
|
143
415
|
* Native 档的 catalog registry:把声明树渲染成 ui-kit 组件。
|
|
144
416
|
* 越界组件名不静默降级,渲染成英文错误行(21 号文档 §8 第 5 条)。
|
|
417
|
+
*
|
|
418
|
+
* 表单行为(草稿跨刷新、必填拦截、默认值)由本组件承接——
|
|
419
|
+
* 节点树取代六类 surface 后,这里是 native 档唯一的渲染实现。
|
|
145
420
|
*/
|
|
146
|
-
declare function NativeSpecSurface({ surfaceId, spec, actions, registry, onAction }: NativeSpecSurfaceProps): import("react").JSX.Element;
|
|
421
|
+
declare function NativeSpecSurface({ surfaceId, spec, actions, registry, runId, draft, onAction, onDraftChange }: NativeSpecSurfaceProps): import("react").JSX.Element;
|
|
147
422
|
//#endregion
|
|
148
423
|
//#region src/catalog/JsonRenderSpecSurface.d.ts
|
|
149
424
|
interface JsonRenderSpecSurfaceProps {
|
|
150
425
|
spec: UiSpecNode;
|
|
426
|
+
surfaceId: string;
|
|
427
|
+
actions?: readonly UiSpecActionCapability[];
|
|
428
|
+
onAction?: (event: CustomSurfaceActionEvent) => void;
|
|
151
429
|
}
|
|
152
430
|
/**
|
|
153
431
|
* `vercel` 档:同一份 catalog 声明树交给 json-render 的 Registry 渲染。
|
|
154
432
|
* `@json-render/*` 是 optional peer,未安装时给出英文说明而不是空白。
|
|
155
433
|
*/
|
|
156
|
-
declare function JsonRenderSpecSurface({ spec }: JsonRenderSpecSurfaceProps): import("react").JSX.Element | null;
|
|
434
|
+
declare function JsonRenderSpecSurface({ spec, surfaceId, actions, onAction }: JsonRenderSpecSurfaceProps): import("react").JSX.Element | null;
|
|
435
|
+
//#endregion
|
|
436
|
+
//#region src/catalog/jsonRenderRegistry.d.ts
|
|
437
|
+
/** catalog 的 action 名与 `UiSpecActionCapability['intent']` 一一对应 */
|
|
438
|
+
type JsonRenderActionDispatch = (intent: string, params: Record<string, unknown>) => void;
|
|
439
|
+
/**
|
|
440
|
+
* registry 是白名单:catalog 之外的组件名在 Renderer 里直接落到 fallback。
|
|
441
|
+
*
|
|
442
|
+
* 工厂而非模块级单例:action 的派发出口要绑定到具体 surface 的回传通道,
|
|
443
|
+
* 模块级单例会让同屏两个 surface 互相串台。
|
|
444
|
+
*/
|
|
445
|
+
declare function createJsonRenderRegistry(dispatch: JsonRenderActionDispatch): DefineRegistryResult;
|
|
446
|
+
//#endregion
|
|
447
|
+
//#region src/interaction/specInteractionChannel.d.ts
|
|
448
|
+
/** 一次待决交互(节点树由 react 层交给本档的 spec surface 渲染) */
|
|
449
|
+
interface SpecInteractionSession {
|
|
450
|
+
request: InteractionRequest;
|
|
451
|
+
spec: UiSpecNode;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* 探测 json-render 渲染器是否可用(@json-render/* 为 optional peer)。
|
|
455
|
+
* 交互视图据此在缺包时调 SpecInteractionChannel.fail,让复合桥粘性降级 native 而不是悬挂请求。
|
|
456
|
+
*/
|
|
457
|
+
declare function probeJsonRenderAvailability(): Promise<boolean>;
|
|
458
|
+
/**
|
|
459
|
+
* 非 native 档的交互通道(路径 A,三档共用):
|
|
460
|
+
* - request() 把 InteractionRequest 经 interactionToUiSpec 转成 catalog 节点树并挂起,
|
|
461
|
+
* react 层订阅 current 后用本档已有的 spec 渲染路径(*SpecSurface)渲染;
|
|
462
|
+
* - 表单提交/取消经 handleAction 回传(submit → shapeInteractionValue;cancel → cancelled);
|
|
463
|
+
* - react 层初始化失败调 fail():挂起请求 reject(桥据此粘性降级 native)并记录原因;
|
|
464
|
+
* - attach/detach 标记渲染视图是否挂载(未挂载时桥直接降级 native,不悬挂请求)。
|
|
465
|
+
*/
|
|
466
|
+
declare class SpecInteractionChannel {
|
|
467
|
+
#private;
|
|
468
|
+
/** 宿主注入的界面文案(本地化);未设时用 FormModel 的英文默认值 */
|
|
469
|
+
labelsFor: (request: InteractionRequest) => InteractionSpecLabels;
|
|
470
|
+
/** React useSyncExternalStore 兼容订阅 */
|
|
471
|
+
subscribe: (listener: () => void) => (() => void);
|
|
472
|
+
get current(): SpecInteractionSession | undefined;
|
|
473
|
+
get isAttached(): boolean;
|
|
474
|
+
/** react 层初始化失败原因(optional peer 未安装等);记录后粘性生效 */
|
|
475
|
+
get failure(): string | undefined;
|
|
476
|
+
attach(): void;
|
|
477
|
+
detach(): void;
|
|
478
|
+
request(input: InteractionRequest): Promise<InteractionResponse>;
|
|
479
|
+
/** runtime 交互超时/取消:以 cancelled resolve 挂起的 request(防悬挂 + 残留) */
|
|
480
|
+
cancel(id: string): void;
|
|
481
|
+
/** react 层动作回传:submit 归形提交值,其余意图(cancel)按取消收尾 */
|
|
482
|
+
handleAction(event: CustomSurfaceActionEvent): void;
|
|
483
|
+
/** react 层初始化失败:挂起请求 reject 并记录原因(桥读取后降级 native) */
|
|
484
|
+
fail(message: string): void;
|
|
485
|
+
}
|
|
157
486
|
//#endregion
|
|
158
487
|
//#region src/catalog/OpenUiSpecSurface.d.ts
|
|
159
488
|
interface OpenUiSpecSurfaceProps {
|
|
160
489
|
spec: UiSpecNode;
|
|
490
|
+
surfaceId: string;
|
|
491
|
+
actions?: readonly UiSpecActionCapability[];
|
|
492
|
+
onAction?: (event: CustomSurfaceActionEvent) => void;
|
|
161
493
|
}
|
|
162
494
|
/**
|
|
163
495
|
* `openui` 档:同一份 catalog 声明树经 openui-lang 交给 OpenUI 的 Renderer。
|
|
164
496
|
* `@openuidev/react-lang` 是 optional peer,未安装时给出英文说明而不是空白。
|
|
165
497
|
*/
|
|
166
|
-
declare function OpenUiSpecSurface({ spec }: OpenUiSpecSurfaceProps): import("react").JSX.Element | null;
|
|
498
|
+
declare function OpenUiSpecSurface({ spec, surfaceId, actions, onAction }: OpenUiSpecSurfaceProps): import("react").JSX.Element | null;
|
|
167
499
|
//#endregion
|
|
168
500
|
//#region src/catalog/catalogComponents.d.ts
|
|
169
501
|
type CatalogNodeProps = {
|
|
@@ -171,10 +503,10 @@ type CatalogNodeProps = {
|
|
|
171
503
|
children?: ReactNode;
|
|
172
504
|
};
|
|
173
505
|
/**
|
|
174
|
-
* catalog
|
|
506
|
+
* catalog 展示类组件的实现:json-render 与 OpenUI 两档共用同一份,
|
|
175
507
|
* 避免"一个 catalog、多套 registry"退化成多套各自演进的视觉。
|
|
176
508
|
* 交互(表单值收集 / action 回传)由各档的宿主组件负责。
|
|
177
509
|
*/
|
|
178
510
|
declare const catalogComponentImpls: Record<string, (input: CatalogNodeProps) => ReactNode>;
|
|
179
511
|
//#endregion
|
|
180
|
-
export { type CatalogNodeProps, type CustomSurfaceActionEvent, InteractionForm, JsonRenderSpecSurface, type JsonRenderSpecSurfaceProps, NATIVE_SPEC_COMPONENTS, NativeSpecSurface, type NativeSpecSurfaceProps, OpenUiSpecSurface, type OpenUiSpecSurfaceProps, ReactBridgeState, type RegisteredSurfaceProps, ResultBlocks, StreamingText, type SurfaceRegistration, SurfaceRegistry, type UiSurfaceActionEvent, UiSurfaceList, type UiSurfaceListProps, UiSurfaceSnapshotList, type UiSurfaceSnapshotListProps, UiSurfaceStore, catalogComponentImpls };
|
|
512
|
+
export { type CatalogNodeProps, type CustomSurfaceActionEvent, type DroppedSurfaceActionWarning, InteractionForm, type JsonRenderActionDispatch, JsonRenderSpecSurface, type JsonRenderSpecSurfaceProps, NATIVE_SPEC_COMPONENTS, NativeSpecSurface, type NativeSpecSurfaceProps, OpenUiSpecSurface, type OpenUiSpecSurfaceProps, ReactBridgeState, type ReactBridgeStateOptions, type RegisteredSurfaceProps, ResultBlocks, SpecInteractionChannel, type SpecInteractionSession, StreamingText, type SurfaceRegistration, SurfaceRegistry, type UiSurfaceActionEvent, UiSurfaceList, type UiSurfaceListProps, UiSurfaceSnapshotList, type UiSurfaceSnapshotListProps, UiSurfaceStore, catalogComponentImpls, createJsonRenderRegistry, probeJsonRenderAvailability };
|