@serene-pub/sdk 0.6.0-pr-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 +202 -0
- package/NOTICE +17 -0
- package/README.md +368 -0
- package/dist/actions.d.ts +572 -0
- package/dist/actions.js +829 -0
- package/dist/annexFields.d.ts +234 -0
- package/dist/annexFields.js +413 -0
- package/dist/announce.d.ts +464 -0
- package/dist/announce.js +426 -0
- package/dist/attributes.d.ts +670 -0
- package/dist/attributes.js +904 -0
- package/dist/bands.d.ts +125 -0
- package/dist/bands.js +256 -0
- package/dist/builder.d.ts +683 -0
- package/dist/builder.js +677 -0
- package/dist/candidates.d.ts +109 -0
- package/dist/candidates.js +118 -0
- package/dist/capabilities.d.ts +744 -0
- package/dist/capabilities.js +679 -0
- package/dist/channels.d.ts +106 -0
- package/dist/channels.js +129 -0
- package/dist/clauses.d.ts +40 -0
- package/dist/clauses.js +43 -0
- package/dist/component.d.ts +33 -0
- package/dist/component.js +27 -0
- package/dist/componentBuild.d.ts +48 -0
- package/dist/componentBuild.js +84 -0
- package/dist/componentClient.d.ts +100 -0
- package/dist/componentClient.js +13 -0
- package/dist/componentImports.d.ts +51 -0
- package/dist/componentImports.js +106 -0
- package/dist/componentModule.d.ts +8 -0
- package/dist/componentModule.js +270 -0
- package/dist/componentWire.d.ts +130 -0
- package/dist/componentWire.js +280 -0
- package/dist/config.d.ts +295 -0
- package/dist/config.js +231 -0
- package/dist/connections.d.ts +89 -0
- package/dist/connections.js +131 -0
- package/dist/declarations.d.ts +290 -0
- package/dist/declarations.js +794 -0
- package/dist/descriptors.d.ts +1774 -0
- package/dist/descriptors.js +1329 -0
- package/dist/dev.d.ts +136 -0
- package/dist/dev.js +161 -0
- package/dist/document.d.ts +202 -0
- package/dist/document.js +312 -0
- package/dist/engines.d.ts +117 -0
- package/dist/engines.js +203 -0
- package/dist/eventMapLaws.d.ts +63 -0
- package/dist/eventMapLaws.js +128 -0
- package/dist/events.d.ts +554 -0
- package/dist/events.js +633 -0
- package/dist/executor.d.ts +771 -0
- package/dist/executor.js +1829 -0
- package/dist/extension.d.ts +448 -0
- package/dist/extension.js +315 -0
- package/dist/facets.d.ts +53 -0
- package/dist/facets.js +60 -0
- package/dist/foldedSections.d.ts +74 -0
- package/dist/foldedSections.js +161 -0
- package/dist/genres.d.ts +507 -0
- package/dist/genres.js +633 -0
- package/dist/guardedConnection.d.ts +138 -0
- package/dist/guardedConnection.js +341 -0
- package/dist/handlebarsReach.d.ts +122 -0
- package/dist/handlebarsReach.js +222 -0
- package/dist/hash.d.ts +146 -0
- package/dist/hash.js +166 -0
- package/dist/hookGrants.d.ts +47 -0
- package/dist/hookGrants.js +68 -0
- package/dist/hooks.d.ts +290 -0
- package/dist/hooks.js +113 -0
- package/dist/hostElements.d.ts +447 -0
- package/dist/hostElements.js +702 -0
- package/dist/i18n.d.ts +94 -0
- package/dist/i18n.js +123 -0
- package/dist/identity.d.ts +93 -0
- package/dist/identity.js +135 -0
- package/dist/index.d.ts +85 -0
- package/dist/index.js +176 -0
- package/dist/layout.d.ts +194 -0
- package/dist/layout.js +40 -0
- package/dist/media.d.ts +202 -0
- package/dist/media.js +70 -0
- package/dist/messageBlocks.d.ts +487 -0
- package/dist/messageBlocks.js +683 -0
- package/dist/migration.d.ts +128 -0
- package/dist/migration.js +261 -0
- package/dist/names.d.ts +78 -0
- package/dist/names.js +136 -0
- package/dist/nodeInput.d.ts +399 -0
- package/dist/nodeInput.js +178 -0
- package/dist/participants.d.ts +291 -0
- package/dist/participants.js +252 -0
- package/dist/personGate.d.ts +62 -0
- package/dist/personGate.js +77 -0
- package/dist/pick.d.ts +84 -0
- package/dist/pick.js +103 -0
- package/dist/pluginHarness.d.ts +235 -0
- package/dist/pluginHarness.js +558 -0
- package/dist/pluginPermissions.d.ts +25 -0
- package/dist/pluginPermissions.js +97 -0
- package/dist/pluginRuleRef.d.ts +13 -0
- package/dist/pluginRuleRef.js +10 -0
- package/dist/predicates.d.ts +182 -0
- package/dist/predicates.js +249 -0
- package/dist/preview.d.ts +120 -0
- package/dist/preview.js +82 -0
- package/dist/promptBlocks.d.ts +130 -0
- package/dist/promptBlocks.js +197 -0
- package/dist/rankingDecisions.d.ts +60 -0
- package/dist/rankingDecisions.js +48 -0
- package/dist/receipt.d.ts +313 -0
- package/dist/receipt.js +60 -0
- package/dist/receiverRules.d.ts +24 -0
- package/dist/receiverRules.js +94 -0
- package/dist/refs.d.ts +117 -0
- package/dist/refs.js +137 -0
- package/dist/registry.d.ts +230 -0
- package/dist/registry.js +273 -0
- package/dist/review.d.ts +108 -0
- package/dist/review.js +97 -0
- package/dist/sampling.d.ts +152 -0
- package/dist/sampling.js +712 -0
- package/dist/scope.d.ts +65 -0
- package/dist/scope.js +128 -0
- package/dist/scripts.d.ts +243 -0
- package/dist/scripts.js +326 -0
- package/dist/sessionLayout.d.ts +339 -0
- package/dist/sessionLayout.js +503 -0
- package/dist/sessionSettings.d.ts +70 -0
- package/dist/sessionSettings.js +2 -0
- package/dist/settings.d.ts +501 -0
- package/dist/settings.js +604 -0
- package/dist/settingsSlot.d.ts +108 -0
- package/dist/settingsSlot.js +166 -0
- package/dist/shapes.d.ts +373 -0
- package/dist/shapes.js +408 -0
- package/dist/sheets.d.ts +165 -0
- package/dist/sheets.js +251 -0
- package/dist/statShapes.d.ts +96 -0
- package/dist/statShapes.js +112 -0
- package/dist/status.d.ts +103 -0
- package/dist/status.js +125 -0
- package/dist/storage.d.ts +145 -0
- package/dist/storage.js +33 -0
- package/dist/storyTime.d.ts +308 -0
- package/dist/storyTime.js +560 -0
- package/dist/surfaces.d.ts +501 -0
- package/dist/surfaces.js +292 -0
- package/dist/template.d.ts +312 -0
- package/dist/template.js +554 -0
- package/dist/templateCheck.d.ts +60 -0
- package/dist/templateCheck.js +516 -0
- package/dist/templateFit.d.ts +157 -0
- package/dist/templateFit.js +349 -0
- package/dist/templateIds.d.ts +138 -0
- package/dist/templateIds.js +144 -0
- package/dist/templateScopeAt.d.ts +131 -0
- package/dist/templateScopeAt.js +354 -0
- package/dist/testing.d.ts +177 -0
- package/dist/testing.js +383 -0
- package/dist/tokenizers.d.ts +113 -0
- package/dist/tokenizers.js +184 -0
- package/dist/turnLock.d.ts +96 -0
- package/dist/turnLock.js +79 -0
- package/dist/turnOrder.d.ts +143 -0
- package/dist/turnOrder.js +128 -0
- package/dist/validate.d.ts +74 -0
- package/dist/validate.js +1399 -0
- package/dist/values.d.ts +212 -0
- package/dist/values.js +390 -0
- package/dist/variables.d.ts +493 -0
- package/dist/variables.js +662 -0
- package/dist/verdicts.d.ts +275 -0
- package/dist/verdicts.js +348 -0
- package/dist/widgetDecls.d.ts +88 -0
- package/dist/widgetDecls.js +119 -0
- package/dist/widgets.d.ts +1527 -0
- package/dist/widgets.js +208 -0
- package/dist/wire.d.ts +126 -0
- package/dist/wire.js +140 -0
- package/dist/worldinfo.d.ts +150 -0
- package/dist/worldinfo.js +212 -0
- package/host-elements.d.ts +914 -0
- package/package.json +67 -0
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declared UI surfaces, and the preview manifest a harness reads from them.
|
|
3
|
+
*
|
|
4
|
+
* A package's UI arrives in exactly two shapes, and the difference is a trust
|
|
5
|
+
* decision, not a taste one:
|
|
6
|
+
*
|
|
7
|
+
* **frame** — a document (`ui/map.html`) mounted in an opaque-origin iframe
|
|
8
|
+
* (`sandbox="allow-scripts"`, never `allow-same-origin`). Zero ambient
|
|
9
|
+
* anything: no cookies, no DOM reach, no socket. Everything it knows arrives
|
|
10
|
+
* on the MessageChannel the host owns (the frame protocol below). This is the
|
|
11
|
+
* shape the app ships today — session-view replacement, page, panel grid
|
|
12
|
+
* (20 §12, 21 §7).
|
|
13
|
+
*
|
|
14
|
+
* **component** — a module the page's UI worker runs (§3.5, R25): one
|
|
15
|
+
* worker per owner per session page, no DOM, no network. It places
|
|
16
|
+
* elements from the host vocabulary (`SP_HOST_ELEMENTS`, `hostElements.ts`)
|
|
17
|
+
* and the host mirrors them into the widget box, dropping anything not
|
|
18
|
+
* listed; its data arrives on the same widget wire a frame's does. A
|
|
19
|
+
* widget names one by `component`; what needs a real document gets one
|
|
20
|
+
* inside the component through `sp-frame`. A frame is a remote minus the
|
|
21
|
+
* worker: the same envelope, a different boundary.
|
|
22
|
+
*
|
|
23
|
+
* The preview harness (`serene-pub preview`) renders both. It reads what the
|
|
24
|
+
* package **announces**, never what a directory happens to contain — a surface
|
|
25
|
+
* a modder sees in the harness is a surface an instance would see in the
|
|
26
|
+
* manifest, or it is a bug in one of them.
|
|
27
|
+
*
|
|
28
|
+
* ## Reading is tolerant on purpose
|
|
29
|
+
*
|
|
30
|
+
* `previewManifest()` never throws on a malformed declaration. The app's
|
|
31
|
+
* `surfacesOf` reads the stored manifest the same way — "a malformed
|
|
32
|
+
* declaration is a missing surface, not a crash" — and a dev harness that
|
|
33
|
+
* dies on a half-typed entry path is a harness that gets closed. Problems come
|
|
34
|
+
* back in `problems[]` so the harness can show them beside the list instead of
|
|
35
|
+
* replacing it.
|
|
36
|
+
*
|
|
37
|
+
* ## The frame protocol (host ⇄ frame, over the transferred port)
|
|
38
|
+
*
|
|
39
|
+
* The types below are the one declaration of the wire the app's `PluginFrame`
|
|
40
|
+
* and the preview harness both speak — both import these unions rather than
|
|
41
|
+
* restating them, so a message a host sends is a message this file declares.
|
|
42
|
+
* They are data, not behaviour: the SDK ships no host and no client, because
|
|
43
|
+
* the host is core's (it owns the scoping) and the client is the author's.
|
|
44
|
+
*
|
|
45
|
+
* What travels is the widget envelope (`widgets.ts`) with the boundary added:
|
|
46
|
+
* a frame receives the same sections a native widget reads off its context,
|
|
47
|
+
* one push per section. `FRAME_PROTOCOL` says which vintage of that wire the
|
|
48
|
+
* host speaks.
|
|
49
|
+
*/
|
|
50
|
+
import type { TurnOrderV1 } from './turnOrder.js';
|
|
51
|
+
import type { ComponentFramework } from './extension.js';
|
|
52
|
+
import type { SettingsSchema } from './settings.js';
|
|
53
|
+
import { type ActionsV1, type AnnexV1, type LayoutV1, type MessageV1, type SessionV1, type ViewerV1, type WidgetRequestKind, type WidgetEvent, type WidgetPayload, type WidgetProtocolVersion, type WidgetScopedSectionName, type WidgetSectionScope } from './widgets.js';
|
|
54
|
+
/**
|
|
55
|
+
* Where a package's entry module lives, in the order the toolchain looks.
|
|
56
|
+
* One list, shared by `serene-pub build` and the preview harness, so "the
|
|
57
|
+
* harness found my plugin but the packager didn't" cannot happen.
|
|
58
|
+
* @experimental
|
|
59
|
+
*/
|
|
60
|
+
export declare const ENTRY_CANDIDATES: readonly ['dist/index.js', 'src/index.ts', 'index.ts', 'index.js'];
|
|
61
|
+
/** One frame surface: the document to mount, and what to call it. @experimental */
|
|
62
|
+
export interface FrameSurfaceDecl {
|
|
63
|
+
/** Path to the document, relative to the package root — `ui/map.html`. */
|
|
64
|
+
entry: string;
|
|
65
|
+
title?: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The widget id a plugin's own panel is seated under: `<pluginId>:<panelId>`.
|
|
69
|
+
*
|
|
70
|
+
* A plugin's widgets are namespaced and core's and a genre's are not, because
|
|
71
|
+
* only a plugin's id is outside anyone's control: a package picks `map` in
|
|
72
|
+
* private and would otherwise collide with every other package that did, and
|
|
73
|
+
* with core's own widgets, in a layout row that outlives the install. The
|
|
74
|
+
* separator can only be `:` — neither grammar admits one — and it is the
|
|
75
|
+
* separator core already uses for an owned id (`core:genre/chat`).
|
|
76
|
+
*
|
|
77
|
+
* Pure: the two halves are NOT validated here. The host reads a stored
|
|
78
|
+
* manifest and knows what it accepted; a helper that refused a second time
|
|
79
|
+
* would have to say so in a second vocabulary, and a composer that can fail is
|
|
80
|
+
* a composer every caller has to branch on. Reading one back DOES validate,
|
|
81
|
+
* because a stored id arrives with no such provenance —
|
|
82
|
+
* {@link parsePluginWidgetId}. The asymmetry is deliberate: composing is the
|
|
83
|
+
* host's own string, parsing is anyone's.
|
|
84
|
+
* @experimental
|
|
85
|
+
*/
|
|
86
|
+
export declare const pluginWidgetId: (pluginId: string, panelId: string) => string;
|
|
87
|
+
/**
|
|
88
|
+
* A namespaced widget id taken back apart, or `null` when the string is not
|
|
89
|
+
* one.
|
|
90
|
+
*
|
|
91
|
+
* `null` is the answer for every core and genre widget id, which is what makes
|
|
92
|
+
* this the test for "is this widget a plugin's": both halves must satisfy the
|
|
93
|
+
* grammars a host would have accepted them under, so exactly the ids
|
|
94
|
+
* {@link pluginWidgetId} can produce round-trip and nothing else does. A
|
|
95
|
+
* second colon lands in the panel half and fails there, so `a:b:c` is not a
|
|
96
|
+
* plugin widget id rather than being read as one with a surprising panel.
|
|
97
|
+
* @experimental
|
|
98
|
+
*/
|
|
99
|
+
export declare function parsePluginWidgetId(id: string): {
|
|
100
|
+
pluginId: string;
|
|
101
|
+
panelId: string;
|
|
102
|
+
} | null;
|
|
103
|
+
/**
|
|
104
|
+
* What a package declares under `surfaces` — the exact shape the app's
|
|
105
|
+
* `frameHost.surfacesOf` reads out of a stored manifest.
|
|
106
|
+
* @experimental
|
|
107
|
+
*/
|
|
108
|
+
export interface SurfacesDecl {
|
|
109
|
+
/**
|
|
110
|
+
* Replaces the whole message section for a genre that names it (19 `view`).
|
|
111
|
+
*
|
|
112
|
+
* Spelled `session-view`, not `sessionView`, because that is the key the
|
|
113
|
+
* app's `surfacesOf` reads out of a stored manifest — and the announcement
|
|
114
|
+
* *is* the manifest (24 §6), so there is no layer in between to translate
|
|
115
|
+
* it. A camelCase spelling here compiled, previewed, installed, and then
|
|
116
|
+
* silently never mounted: the exact class of bug this file's docstring
|
|
117
|
+
* claims cannot happen. One spelling, end to end.
|
|
118
|
+
*/
|
|
119
|
+
'session-view'?: FrameSurfaceDecl;
|
|
120
|
+
/** A standalone page under the app's plugin route shell. */
|
|
121
|
+
page?: FrameSurfaceDecl;
|
|
122
|
+
}
|
|
123
|
+
/** The three frame points, spelled as the app spells them. @experimental */
|
|
124
|
+
export type FramePoint = 'session-view' | 'page' | 'panel';
|
|
125
|
+
/**
|
|
126
|
+
* 🚧 Why a request was declined, when a component may act on the reason
|
|
127
|
+
* rather than its sentence — the `code` of a declining `response`, and of
|
|
128
|
+
* the error a component's `request` rejects with ({@link RequestDeclined}).
|
|
129
|
+
* `unmounted`: the component was unmounted before its request was answered
|
|
130
|
+
* — nothing is wrong, nobody is left to tell. Additive: a host that sends
|
|
131
|
+
* none still declines with its sentence alone.
|
|
132
|
+
* @experimental
|
|
133
|
+
*/
|
|
134
|
+
export type RequestDeclineCode = 'unmounted';
|
|
135
|
+
/**
|
|
136
|
+
* host → frame. `init` carries the port; everything after rides it.
|
|
137
|
+
*
|
|
138
|
+
* The same union types a component's wire (`componentWire.ts`): a few
|
|
139
|
+
* members (`settings`, `layout`, `scoped`, `grants`) are widget data that
|
|
140
|
+
* only a component is sent — a frame never is one.
|
|
141
|
+
* @experimental
|
|
142
|
+
*/
|
|
143
|
+
export type HostFrameMessage = {
|
|
144
|
+
t: 'init';
|
|
145
|
+
protocol: FrameProtocolVersion;
|
|
146
|
+
surface: FramePoint;
|
|
147
|
+
payload?: unknown;
|
|
148
|
+
} | {
|
|
149
|
+
t: 'session';
|
|
150
|
+
session: SessionV1;
|
|
151
|
+
} | {
|
|
152
|
+
t: 'messages';
|
|
153
|
+
messages: MessageV1[];
|
|
154
|
+
} | {
|
|
155
|
+
t: 'message';
|
|
156
|
+
message: MessageV1;
|
|
157
|
+
} | {
|
|
158
|
+
t: 'channel';
|
|
159
|
+
channel: string;
|
|
160
|
+
messages: MessageV1[];
|
|
161
|
+
} | {
|
|
162
|
+
t: 'props';
|
|
163
|
+
props: WidgetPayload;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* This instance's effective settings — the widget envelope's `settings.v1`,
|
|
167
|
+
* every declared field defaulted with the person's deviations over it,
|
|
168
|
+
* read as `ctx.settings`. Sent over a component's wire only: no frame is a
|
|
169
|
+
* widget (the `surface` shortcut retired 2026-10-02), so none receives it.
|
|
170
|
+
*/
|
|
171
|
+
| {
|
|
172
|
+
t: 'settings';
|
|
173
|
+
settings: WidgetPayload;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* This widget's placement — the envelope's `layout.v1`, projected by the
|
|
177
|
+
* host and detached, so a later host-side move cannot reach into a message
|
|
178
|
+
* already sent. Re-sent on every change, and re-sent on reload. Sent over
|
|
179
|
+
* a component's wire only, never to a frame.
|
|
180
|
+
*/
|
|
181
|
+
| {
|
|
182
|
+
t: 'layout';
|
|
183
|
+
layout: LayoutV1;
|
|
184
|
+
}
|
|
185
|
+
/** The viewer's view of the session annex (R57), on open and on every change — `annex.v1`. */
|
|
186
|
+
| {
|
|
187
|
+
t: 'annex';
|
|
188
|
+
annex: AnnexV1;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* One host event — the port's analog of the `on` verb, and the same union a
|
|
192
|
+
* native widget subscribes to. Scoped to the frame's declared channels
|
|
193
|
+
* host-side, exactly as the message posts are, so a frame is never told
|
|
194
|
+
* about a message it was not also sent. Widget surfaces only.
|
|
195
|
+
*/
|
|
196
|
+
| {
|
|
197
|
+
t: 'event';
|
|
198
|
+
event: WidgetEvent;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* The session's actions per venue — the envelope's `actions.v1`. A frame
|
|
202
|
+
* fires one with `{ t: 'invoke' }`, which the host resolves to the
|
|
203
|
+
* declaration exactly as the native `invoke` verb does. Widget surfaces
|
|
204
|
+
* only.
|
|
205
|
+
*/
|
|
206
|
+
| {
|
|
207
|
+
t: 'actions';
|
|
208
|
+
actions: ActionsV1;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* The host's active theme, as data (10 §6: *"the active theme id is a
|
|
212
|
+
* prop"*). An in-document component reads it off `ctx.theme`; a frame is
|
|
213
|
+
* its own document, so it arrives here.
|
|
214
|
+
*
|
|
215
|
+
* Values, never tokens. RESEARCH §7b is explicit that SP publishes no
|
|
216
|
+
* token artifact of any kind — the frame applies the id and the mode to
|
|
217
|
+
* its own `<html>` (`data-theme` / `data-mode`) and lets the stylesheet it
|
|
218
|
+
* linked resolve them, exactly as the top document does. That keeps the
|
|
219
|
+
* token surface "whatever Skeleton version core currently ships" rather
|
|
220
|
+
* than a list this union would have to maintain.
|
|
221
|
+
*
|
|
222
|
+
* Sent once the frame is ready and again whenever the host's theme or mode
|
|
223
|
+
* changes. A frame is still free to ignore it and keep its own look: the
|
|
224
|
+
* host's CSP grants the frame its OWN files, so a stylesheet resolving
|
|
225
|
+
* these attributes is one the package ships, not one it inherits.
|
|
226
|
+
*/
|
|
227
|
+
| {
|
|
228
|
+
t: 'theme';
|
|
229
|
+
theme: string;
|
|
230
|
+
mode: 'light' | 'dark';
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* The viewer's language code — the envelope's `locale.v1` — sent once the
|
|
234
|
+
* frame is ready and again if it changes, so a frame renders locale maps
|
|
235
|
+
* (`i18nText`) in the page's language.
|
|
236
|
+
*/
|
|
237
|
+
| {
|
|
238
|
+
t: 'locale';
|
|
239
|
+
locale: string;
|
|
240
|
+
} | {
|
|
241
|
+
t: 'suspend';
|
|
242
|
+
} | {
|
|
243
|
+
t: 'resume';
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* A page of whatever the frame last asked for, echoing its `requestId`.
|
|
247
|
+
* Without this a frame had no way to ask for anything: `messages` and
|
|
248
|
+
* `channel` arrive when the host feels like sending them, so a long channel
|
|
249
|
+
* could only be rendered in whatever slice the host chose.
|
|
250
|
+
*/
|
|
251
|
+
| {
|
|
252
|
+
t: 'page';
|
|
253
|
+
requestId: string;
|
|
254
|
+
rows: unknown[];
|
|
255
|
+
nextCursor?: string;
|
|
256
|
+
}
|
|
257
|
+
/** The frame's own persisted view state, restored on (re)mount — see
|
|
258
|
+
* `save-state`. */
|
|
259
|
+
| {
|
|
260
|
+
t: 'state';
|
|
261
|
+
state: Record<string, unknown>;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* 🚧 The answer to any `request` but `messages` (C0b), echoing its
|
|
265
|
+
* `requestId`: `ok` with the kind's result, or declined with why — and,
|
|
266
|
+
* when the decline is one a component may tell apart, its
|
|
267
|
+
* {@link RequestDeclineCode} (`code`; absent from an older host).
|
|
268
|
+
*/
|
|
269
|
+
| {
|
|
270
|
+
t: 'response';
|
|
271
|
+
requestId: string;
|
|
272
|
+
ok: boolean;
|
|
273
|
+
result?: unknown;
|
|
274
|
+
error?: string;
|
|
275
|
+
code?: RequestDeclineCode;
|
|
276
|
+
}
|
|
277
|
+
/** 🚧 Translations of strings the frame asked for with `translate` (C0b). */
|
|
278
|
+
| {
|
|
279
|
+
t: 'strings';
|
|
280
|
+
strings: Record<string, string>;
|
|
281
|
+
}
|
|
282
|
+
/** 🚧 Who is looking — the envelope's `viewer.v1` (C0b). */
|
|
283
|
+
| {
|
|
284
|
+
t: 'viewer';
|
|
285
|
+
viewer: ViewerV1;
|
|
286
|
+
}
|
|
287
|
+
/** The session's turn order — the envelope's `turnOrder.v1` (C5), on open and on every change. */
|
|
288
|
+
| {
|
|
289
|
+
t: 'turn-order';
|
|
290
|
+
turnOrder: TurnOrderV1;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* 🚧 A scoped section the widget was granted (C0b) — named as the SDK's
|
|
294
|
+
* one table posts it (`WidgetScopedSections`: `session_full`,
|
|
295
|
+
* `session_state`, `persona`, `characters`, `lore`), the envelope's
|
|
296
|
+
* `<name>.v1` — posted when it changes; `value: null` withdraws it (the
|
|
297
|
+
* grant went away). Never posted to a widget not granted it. Sent over a
|
|
298
|
+
* component's wire only, never to a frame.
|
|
299
|
+
*/
|
|
300
|
+
| {
|
|
301
|
+
t: 'scoped';
|
|
302
|
+
section: WidgetScopedSectionName;
|
|
303
|
+
value: unknown;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* 🚧 The scopes the widget holds, BARE (`session:state`, never the
|
|
307
|
+
* permission key `widget:session:state`) — sent before the first push
|
|
308
|
+
* of its sections and again whenever they change (an admin grants or
|
|
309
|
+
* revokes one while it is open). What lets a widget tell a scope that was
|
|
310
|
+
* NOT granted (its section will never come: say so) from one whose
|
|
311
|
+
* section has not been posted yet (wait): both are an absent `scoped`.
|
|
312
|
+
* Sent over a component's wire only, never to a frame.
|
|
313
|
+
*/
|
|
314
|
+
| {
|
|
315
|
+
t: 'grants';
|
|
316
|
+
grants: WidgetSectionScope[];
|
|
317
|
+
};
|
|
318
|
+
/**
|
|
319
|
+
* frame → host. Deliberately tiny: a frame proposes, the host decides.
|
|
320
|
+
*
|
|
321
|
+
* Tiny is not the same as mute. A frame that fails to boot has to be able to
|
|
322
|
+
* say so (`error`); a frame showing a long channel has to be able to page
|
|
323
|
+
* (`request`); a frame with view state has to be able to keep it across a
|
|
324
|
+
* remount (`save-state`); and a frame pressing one of the session's own
|
|
325
|
+
* actions has to be able to name it (`invoke`). None of those is the host
|
|
326
|
+
* giving up control — they are the frame reporting, requesting and naming,
|
|
327
|
+
* with the host still deciding.
|
|
328
|
+
* @experimental
|
|
329
|
+
*/
|
|
330
|
+
export type FrameHostMessage = {
|
|
331
|
+
t: 'ready';
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* ⏳ Fire a function by name.
|
|
335
|
+
*
|
|
336
|
+
* @deprecated Send `invoke` instead. A press names a DECLARATION by its
|
|
337
|
+
* identity: a bare `fn` is a key, which several specs may declare, and it
|
|
338
|
+
* gets the server's narrowest reading — the one declarer it names, or a
|
|
339
|
+
* refusal — rather than the one the frame meant. Accepted for one release — the host still routes it — and it
|
|
340
|
+
* is the frame half of `WidgetVerbs.action`'s deprecation.
|
|
341
|
+
*/
|
|
342
|
+
| {
|
|
343
|
+
t: 'action';
|
|
344
|
+
fn: string;
|
|
345
|
+
messageId?: number;
|
|
346
|
+
payload?: WidgetPayload;
|
|
347
|
+
/** The identity the outlet stamped a form block with (W-E) — carried, never chosen. */
|
|
348
|
+
action?: string;
|
|
349
|
+
/** The form the press answers: a block's id within `messageId`. */
|
|
350
|
+
blockId?: string;
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Fire an action the host listed in `actions`, by its **identity**
|
|
354
|
+
* (`<spec slug>#<key>`) or, when only one action carries it, its bare
|
|
355
|
+
* **key**. The host resolves it against the very projection it sent and
|
|
356
|
+
* routes it — one of core's verbs to its real handler, a contributed one to
|
|
357
|
+
* the audited fire with its identity attached.
|
|
358
|
+
*
|
|
359
|
+
* A key no venue lists, and a bare key several actions share, is dropped
|
|
360
|
+
* with a warning: a frame cannot fire something the session does not offer,
|
|
361
|
+
* or something ambiguous, and believe it did. A state-changing verb also
|
|
362
|
+
* wants a person in the frame — the host judges that, and the server
|
|
363
|
+
* re-judges the write.
|
|
364
|
+
*/
|
|
365
|
+
| {
|
|
366
|
+
t: 'invoke';
|
|
367
|
+
key: string;
|
|
368
|
+
messageId?: number;
|
|
369
|
+
payload?: WidgetPayload;
|
|
370
|
+
/**
|
|
371
|
+
* The form this press answers — a block's id within `messageId`
|
|
372
|
+
* (R-15 *Forms*). Absent on every other press; the frame half of
|
|
373
|
+
* `WidgetInvokeArgs.blockId`.
|
|
374
|
+
*/
|
|
375
|
+
blockId?: string;
|
|
376
|
+
/** The text the press supplies (a slash argument) — the frame half of `WidgetInvokeArgs.text`. */
|
|
377
|
+
text?: string;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Something went wrong inside the frame. The host logs it against the
|
|
381
|
+
* plugin and may surface it in the panel's chrome — which is the whole
|
|
382
|
+
* point: a broken total-conversion surface should say so rather than sit
|
|
383
|
+
* blank.
|
|
384
|
+
*/
|
|
385
|
+
| {
|
|
386
|
+
t: 'error';
|
|
387
|
+
message: string;
|
|
388
|
+
detail?: unknown;
|
|
389
|
+
fatal?: boolean;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Ask for a page of a channel's messages. The host answers with `page`
|
|
393
|
+
* carrying the same `requestId`, or declines silently — a request is not a
|
|
394
|
+
* grant.
|
|
395
|
+
*/
|
|
396
|
+
| {
|
|
397
|
+
t: 'request';
|
|
398
|
+
requestId: string;
|
|
399
|
+
what: 'messages';
|
|
400
|
+
channel?: string;
|
|
401
|
+
cursor?: string;
|
|
402
|
+
limit?: number;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* 🚧 Ask the host for anything else in {@link WidgetRequests} (C0b) — a
|
|
406
|
+
* host view opened, a picker shown. Answered with `response`.
|
|
407
|
+
*/
|
|
408
|
+
| {
|
|
409
|
+
t: 'request';
|
|
410
|
+
requestId: string;
|
|
411
|
+
what: Exclude<WidgetRequestKind, 'messages'>;
|
|
412
|
+
params: unknown;
|
|
413
|
+
}
|
|
414
|
+
/** 🚧 English UI strings the frame wants in the viewer's language (C0b); answered with `strings`. */
|
|
415
|
+
| {
|
|
416
|
+
t: 'translate';
|
|
417
|
+
sources: string[];
|
|
418
|
+
}
|
|
419
|
+
/** Persist small view state (a scroll offset, an open tab). Returned as
|
|
420
|
+
* `state` on the next mount. Not storage: the host may cap or drop it. */
|
|
421
|
+
| {
|
|
422
|
+
t: 'save-state';
|
|
423
|
+
state: Record<string, unknown>;
|
|
424
|
+
};
|
|
425
|
+
/**
|
|
426
|
+
* The version the host announces in `init`, and the number a frame reads to
|
|
427
|
+
* know what it may send.
|
|
428
|
+
*
|
|
429
|
+
* **2 comprises** everything declared in the two unions above: the widget
|
|
430
|
+
* envelope's sections as pushes (`settings`, `layout`, `event`,
|
|
431
|
+
* `actions`) alongside `session` / `messages` / `message` / `channel` /
|
|
432
|
+
* `props` / `theme` / `suspend` / `resume`, and, frame → host, `invoke`
|
|
433
|
+
* beside `ready` and `action`, plus `error`, `request` and `save-state` with
|
|
434
|
+
* their `page` and `state` replies.
|
|
435
|
+
*
|
|
436
|
+
* A host may DECLINE any of the last three and still be a v2 host: a `request`
|
|
437
|
+
* is not a grant, `save-state` may be capped or dropped, and an `error` may go
|
|
438
|
+
* no further than a log. What 2 promises is that the frame may send them
|
|
439
|
+
* without breaking the wire — never that the host will act on them. A frame
|
|
440
|
+
* that needs an answer must therefore tolerate not getting one, just as it
|
|
441
|
+
* ignores a host message it has never heard of.
|
|
442
|
+
*
|
|
443
|
+
* A v1 frame keeps working unchanged: it never sends the frame → host
|
|
444
|
+
* additions, and it must already ignore host messages it does not recognise. A
|
|
445
|
+
* v2 host must still accept `init` from a v1 frame — the version says what the
|
|
446
|
+
* frame *may* send, not what it must.
|
|
447
|
+
*
|
|
448
|
+
* ONE number with the native lane (`WIDGET_PROTOCOL`): native is frame minus
|
|
449
|
+
* the iframe, so a second clock here would be a second contract by accident.
|
|
450
|
+
* @experimental
|
|
451
|
+
*/
|
|
452
|
+
export declare const FRAME_PROTOCOL: 2;
|
|
453
|
+
/** @experimental */
|
|
454
|
+
export type FrameProtocolVersion = WidgetProtocolVersion;
|
|
455
|
+
/** One thing the harness can put on screen. @experimental */
|
|
456
|
+
export interface PreviewTarget {
|
|
457
|
+
/** URL-safe, unique within the manifest — the harness routes on it. */
|
|
458
|
+
id: string;
|
|
459
|
+
label: string;
|
|
460
|
+
kind: 'frame' | 'component';
|
|
461
|
+
/**
|
|
462
|
+
* For a frame, one of `FramePoint`. For a component, the mount point it
|
|
463
|
+
* renders at — `widget` today (a page mount point comes later, R25).
|
|
464
|
+
*/
|
|
465
|
+
point: string;
|
|
466
|
+
/** Path to the entry, exactly as declared — relative to the package root. */
|
|
467
|
+
entry: string;
|
|
468
|
+
/** Components only: which adapter renders it (10 §7). */
|
|
469
|
+
framework?: ComponentFramework;
|
|
470
|
+
/** Components only: settings the target reads through `ctx` (12 §6). */
|
|
471
|
+
settings?: SettingsSchema;
|
|
472
|
+
/** Where the declaration came from, for the harness's "declared in" line. */
|
|
473
|
+
source: 'surfaces' | 'components';
|
|
474
|
+
}
|
|
475
|
+
/** @experimental */
|
|
476
|
+
export interface PreviewManifest {
|
|
477
|
+
/** The package's address — an announce ns (`acme.dice`) or a plugin slug. */
|
|
478
|
+
id: string;
|
|
479
|
+
title: string;
|
|
480
|
+
version?: string;
|
|
481
|
+
targets: PreviewTarget[];
|
|
482
|
+
/**
|
|
483
|
+
* Declarations that could not be read. Shown beside the list, never thrown:
|
|
484
|
+
* a half-typed entry path must not empty the harness.
|
|
485
|
+
*/
|
|
486
|
+
problems: string[];
|
|
487
|
+
}
|
|
488
|
+
/** Would an instance serve this entry path, or quietly drop the surface? @internal */
|
|
489
|
+
export declare const isServableEntry: (path: string) => boolean;
|
|
490
|
+
/** Would an instance accept this panel id, or quietly drop the panel? @internal */
|
|
491
|
+
export declare const isServablePanelId: (id: string) => boolean;
|
|
492
|
+
/**
|
|
493
|
+
* Read a package's UI declarations into the harness's list.
|
|
494
|
+
*
|
|
495
|
+
* Takes the entry module's default export: a `defineExtension` result. An
|
|
496
|
+
* `AnnouncementBuilder` or a compiled `AnnouncementDocument` is still read, for
|
|
497
|
+
* packages built before `defineExtension` became the one entry.
|
|
498
|
+
* @experimental
|
|
499
|
+
*/
|
|
500
|
+
export declare function previewManifest(entry: unknown): PreviewManifest;
|
|
501
|
+
//# sourceMappingURL=surfaces.d.ts.map
|