@salesforce/platform-sdk 11.4.7 → 11.6.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/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/view.d.ts +85 -40
- package/dist/core/view.d.ts.map +1 -1
- package/dist/data/index.js +1 -1
- package/dist/view/embedding.d.ts +93 -3
- package/dist/view/embedding.d.ts.map +1 -1
- package/dist/view/index.d.ts +1 -1
- package/dist/view/index.d.ts.map +1 -1
- package/dist/view/index.js +201 -66
- package/package.json +2 -2
package/dist/core/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export { Surface, getVerifiedSurface, initialize, isSfEmbeddingIframe, resetSurf
|
|
|
7
7
|
export type { InitializeOptions } from './surface';
|
|
8
8
|
export type { SDKOptions } from './options';
|
|
9
9
|
export type { HostContext, HostStyles, ChatMessage, ChatSDK, ContentBlock, DeviceCapabilities, DisplayMode, ResourceRequest, SafeAreaInsets, SetWidgetStateOptions, ToolCall, ToolState, } from './chat';
|
|
10
|
-
export type { AlertOptions, MessageLevel, ModalOptions, ToastOptions, Theme, ThemeMode, ViewSDK, } from './view';
|
|
10
|
+
export type { AlertOptions, MessageLevel, ModalOptions, ToastOptions, Theme, ThemeMode, UiState, UiStyles, ViewSDK, } from './view';
|
|
11
11
|
export type { CacheControl, DataSDK, DataSDKGraphQL, GraphQLError, GraphQLRawDocument, GraphQLRequest, GraphQLResponse, MutateOptions, MutationResult, QueryOptions, QueryResult, QuerySubscriber, Unsubscribe, } from './data';
|
|
12
12
|
export type { LightningSDK, LMSMessage, LMSSubscription, MessageChannel } from './lightning';
|
|
13
13
|
export type { OpenAISDK } from './platforms';
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACN,O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adjacent styling the host publishes for the embedded surface.
|
|
8
|
+
*
|
|
9
|
+
* `variables` are CSS custom properties (`--*`) read off the host element's inline
|
|
10
|
+
* style; `attributes` are mirrored a11y/i18n/input attributes from the host LWC.
|
|
11
|
+
*/
|
|
12
|
+
export interface UiStyles {
|
|
13
|
+
variables?: Record<string, string>;
|
|
14
|
+
attributes?: Record<string, string>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Host → embedding rendering snapshot exposed to bundles via {@link ViewSDK.getUiState}.
|
|
18
|
+
*
|
|
19
|
+
* `props` are host-configurable inputs (theme, locale, mode, etc.); `styles` are the
|
|
20
|
+
* CSS custom properties and attributes the host wants mirrored onto the surface.
|
|
21
|
+
*
|
|
22
|
+
* Declared locally (not re-exported from `@salesforce/sf-embedding-bridge`) to keep the
|
|
23
|
+
* wire-layer package off the SDK's public type graph; the shape mirrors the bridge's, so
|
|
24
|
+
* surface-side code assigns without a cast.
|
|
25
|
+
*
|
|
26
|
+
* This is the open, fully-permissive shape. A bundle that knows its host contract can
|
|
27
|
+
* declare a narrower type that `extends UiState` (tighter `props`/`styles`) and pass it to
|
|
28
|
+
* {@link ViewSDK.getUiState}'s single type parameter for precise typing.
|
|
29
|
+
*/
|
|
30
|
+
export interface UiState {
|
|
31
|
+
props: Record<string, unknown>;
|
|
32
|
+
styles: UiStyles;
|
|
33
|
+
}
|
|
6
34
|
/**
|
|
7
35
|
* Theme mode
|
|
8
36
|
*/
|
|
@@ -93,6 +121,19 @@ export interface ModalOptions {
|
|
|
93
121
|
* alerts, toast notifications, modal dialogs, and managing application state. All methods
|
|
94
122
|
* are optional and may not be available depending on the runtime surface.
|
|
95
123
|
*
|
|
124
|
+
* ## Events
|
|
125
|
+
*
|
|
126
|
+
* A ViewSDK is a DOM {@link EventTarget}: the event API is the native
|
|
127
|
+
* `addEventListener` / `removeEventListener` / `dispatchEvent`. On surfaces backed by a
|
|
128
|
+
* host bridge (e.g. the embedded MicroFrontend surface), `dispatchEvent` both notifies
|
|
129
|
+
* local listeners and forwards the event to the host, and events pushed by the host are
|
|
130
|
+
* re-dispatched onto the SDK so `addEventListener` hears them too — one unified stream of
|
|
131
|
+
* host-pushed and same-document events.
|
|
132
|
+
*
|
|
133
|
+
* The `EventTarget` members are declared via {@link Partial} so that surfaces without an
|
|
134
|
+
* event bus (e.g. the WebApp/Mosaic degraded SDK, which is a bare `{}`) still satisfy the
|
|
135
|
+
* type. Feature-detect before use: `viewSDK.dispatchEvent?.(...)`.
|
|
136
|
+
*
|
|
96
137
|
* @example
|
|
97
138
|
* ```typescript
|
|
98
139
|
* const viewSDK = await createViewSDK();
|
|
@@ -103,11 +144,17 @@ export interface ModalOptions {
|
|
|
103
144
|
* level: 'success'
|
|
104
145
|
* });
|
|
105
146
|
*
|
|
147
|
+
* // Listen for events (host-pushed or same-document) and dispatch your own
|
|
148
|
+
* viewSDK.addEventListener?.('user-action', (e) => {
|
|
149
|
+
* console.log('received:', (e as CustomEvent).detail);
|
|
150
|
+
* });
|
|
151
|
+
* viewSDK.dispatchEvent?.(new CustomEvent('user-action', { detail: { action: 'click' } }));
|
|
152
|
+
*
|
|
106
153
|
* // Mark application as having unsaved changes
|
|
107
154
|
* await viewSDK.markDirtyState?.();
|
|
108
155
|
* ```
|
|
109
156
|
*/
|
|
110
|
-
export
|
|
157
|
+
export type ViewSDK = Partial<EventTarget> & {
|
|
111
158
|
/**
|
|
112
159
|
* Display an alert message in the host environment
|
|
113
160
|
*
|
|
@@ -226,52 +273,50 @@ export interface ViewSDK {
|
|
|
226
273
|
*/
|
|
227
274
|
clearDirtyState?(label?: string): Promise<void>;
|
|
228
275
|
/**
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
* This allows the application to send custom events with associated data to the
|
|
232
|
-
* host. The host can listen for these events and respond accordingly.
|
|
276
|
+
* Get the current host UI state and a `subscribe` function for future changes.
|
|
233
277
|
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
* ```typescript
|
|
240
|
-
* await viewSDK.dispatchEvent?.('user-action', {
|
|
241
|
-
* action: 'click',
|
|
242
|
-
* buttonId: 'submit',
|
|
243
|
-
* timestamp: Date.now()
|
|
244
|
-
* });
|
|
245
|
-
* ```
|
|
246
|
-
*/
|
|
247
|
-
dispatchEvent?(event: string, data: Record<string, unknown>): Promise<void>;
|
|
248
|
-
/**
|
|
249
|
-
* Get UI properties from the host and subscribe to changes
|
|
278
|
+
* Returns the latest known snapshot synchronously — the underlying wire subscription is
|
|
279
|
+
* opened once, is session-scoped, and is shared across every caller ({@link getTheme} is
|
|
280
|
+
* its synchronous sibling). Call `subscribe` with a handler to be notified on every
|
|
281
|
+
* subsequent host push; `subscribe` returns an `unsubscribe` function that detaches that
|
|
282
|
+
* one handler. Detaching is local fan-out only — the shared wire subscription stays open.
|
|
250
283
|
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
284
|
+
* The optional `State` type parameter describes the host contract this caller expects:
|
|
285
|
+
* pass a type that `extends UiState` (narrower `props`/`styles`) and both `state` and the
|
|
286
|
+
* `subscribe` handler's argument are typed as it. It defaults to the open {@link UiState},
|
|
287
|
+
* so `getUiState()` with no type argument is the fully-permissive snapshot. `State` is
|
|
288
|
+
* erased at runtime — purely a compile-time convenience, so pin only what the host
|
|
289
|
+
* actually guarantees.
|
|
254
290
|
*
|
|
255
|
-
* @
|
|
291
|
+
* @typeParam State - The expected snapshot shape; must extend {@link UiState}.
|
|
292
|
+
* @returns `{ state, subscribe }` — the current snapshot and a subscribe function whose
|
|
293
|
+
* return value is the per-handler `unsubscribe`.
|
|
256
294
|
*
|
|
257
295
|
* @example
|
|
258
296
|
* ```typescript
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
*
|
|
297
|
+
* // Untyped — the permissive default.
|
|
298
|
+
* const { state, subscribe } = viewSDK.getUiState?.() ?? {
|
|
299
|
+
* state: { props: {}, styles: {} },
|
|
300
|
+
* subscribe: () => () => {},
|
|
301
|
+
* };
|
|
302
|
+
* applyProps(state.props);
|
|
303
|
+
* const unsubscribe = subscribe((next) => applyProps(next.props));
|
|
304
|
+
* unsubscribe(); // later, when the caller no longer cares
|
|
305
|
+
*
|
|
306
|
+
* // Typed — pin the exact snapshot the host guarantees.
|
|
307
|
+
* interface MyUiState extends UiState {
|
|
308
|
+
* props: { theme: "light" | "dark" };
|
|
309
|
+
* styles: { variables?: { "--accent": string } };
|
|
310
|
+
* }
|
|
311
|
+
* const { state } = viewSDK.getUiState?.<MyUiState>() ??
|
|
312
|
+
* { state: { props: { theme: "light" }, styles: {} } };
|
|
313
|
+
* state.props.theme; // "light" | "dark"
|
|
314
|
+
* state.styles.variables?.["--accent"]; // string | undefined
|
|
270
315
|
* ```
|
|
271
316
|
*/
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
subscribe: (
|
|
317
|
+
getUiState?<State extends UiState = UiState>(): {
|
|
318
|
+
state: State;
|
|
319
|
+
subscribe: (handler: (state: State) => void) => () => void;
|
|
275
320
|
};
|
|
276
321
|
/**
|
|
277
322
|
* Resize the application viewport
|
|
@@ -310,5 +355,5 @@ export interface ViewSDK {
|
|
|
310
355
|
* ```
|
|
311
356
|
*/
|
|
312
357
|
getTheme?(): Theme | null;
|
|
313
|
-
}
|
|
358
|
+
};
|
|
314
359
|
//# sourceMappingURL=view.d.ts.map
|
package/dist/core/view.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/core/view.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;AAEzC;;GAEG;AACH,MAAM,WAAW,KAAK;IACrB,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,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAyCG;IACH,UAAU,CAAC,CAAC,KAAK,SAAS,OAAO,GAAG,OAAO,KAAK;QAC/C,KAAK,EAAE,KAAK,CAAC;QACb,SAAS,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;KAC3D,CAAC;IAEF;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtD;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CAAC,IAAI,KAAK,GAAG,IAAI,CAAC;CAC1B,CAAC"}
|
package/dist/data/index.js
CHANGED
|
@@ -196,7 +196,7 @@ class ie {
|
|
|
196
196
|
})).structuredContent;
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
-
const ce = "X-SFDC-Client-Name", ue = "X-SFDC-Client-Version", he = "@salesforce/platform-sdk", le = "11.
|
|
199
|
+
const ce = "X-SFDC-Client-Name", ue = "X-SFDC-Client-Version", he = "@salesforce/platform-sdk", le = "11.6.0", de = (t) => {
|
|
200
200
|
let e = y(ce, he, t);
|
|
201
201
|
return e = y(ue, le, e), u(e);
|
|
202
202
|
}, pe = "X-CSRF-Token";
|
package/dist/view/embedding.d.ts
CHANGED
|
@@ -1,15 +1,105 @@
|
|
|
1
|
-
import { ViewSDK } from '../core';
|
|
1
|
+
import { UiState, ViewSDK } from '../core';
|
|
2
2
|
/** Pixel-only dimension string: bare number or `Npx`. The empty string is allowed so a caller can omit one axis. */
|
|
3
3
|
export type PixelSize = `${number}` | `${number}px` | "";
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* ViewSDK for the sf-embedding surface; wraps bridge wire-layer primitives.
|
|
6
|
+
*
|
|
7
|
+
* This SDK **is** a DOM {@link EventTarget}: the public event API is the native
|
|
8
|
+
* `addEventListener` / `removeEventListener` / `dispatchEvent`. Events flow through it in
|
|
9
|
+
* both directions and are unified into a single stream:
|
|
10
|
+
*
|
|
11
|
+
* - **Outbound** — {@link dispatchEvent} both notifies local listeners (via the native
|
|
12
|
+
* {@link EventTarget}) *and* forwards the event to the host over the wire.
|
|
13
|
+
* - **Inbound** — events the host pushes over the wire are re-dispatched onto this
|
|
14
|
+
* `EventTarget`, so `addEventListener` consumers hear host-pushed and same-document
|
|
15
|
+
* events alike.
|
|
16
|
+
*
|
|
17
|
+
* The wire is host-trusted; same-document dispatches are not. Consumers that must trust
|
|
18
|
+
* the origin of an event should validate its payload rather than assume it came from the
|
|
19
|
+
* host.
|
|
20
|
+
*/
|
|
21
|
+
export declare class EmbeddingViewSDK extends EventTarget implements ViewSDK {
|
|
6
22
|
private readonly session;
|
|
7
23
|
static create(): Promise<EmbeddingViewSDK>;
|
|
24
|
+
private currentUiState;
|
|
25
|
+
private readonly uiStateListeners;
|
|
8
26
|
private constructor();
|
|
27
|
+
/**
|
|
28
|
+
* Dispatch a custom event.
|
|
29
|
+
*
|
|
30
|
+
* Overrides {@link EventTarget.dispatchEvent} to be symmetric across both channels an
|
|
31
|
+
* embedded bundle can reach: it forwards the event to the host over the wire **and**
|
|
32
|
+
* notifies local listeners on this `EventTarget`. A {@link CustomEvent}'s `detail` is
|
|
33
|
+
* the payload sent to the host; a plain `Event` (no `detail`) is delivered to local
|
|
34
|
+
* listeners only, since there is nothing to carry over the wire.
|
|
35
|
+
*
|
|
36
|
+
* A bundle's own dispatch reaches its own listeners exactly once — synchronously, here
|
|
37
|
+
* — and is not echoed back: the host does not relay a bundle's own dispatch down the
|
|
38
|
+
* wire to the originating iframe (inbound re-dispatch goes through `super.dispatchEvent`,
|
|
39
|
+
* never back out through this override).
|
|
40
|
+
*
|
|
41
|
+
* @param event - The event to dispatch. Use a {@link CustomEvent} to carry a payload.
|
|
42
|
+
* @returns `false` if the event is cancelable and a listener called `preventDefault()`,
|
|
43
|
+
* otherwise `true` (native {@link EventTarget} semantics).
|
|
44
|
+
*/
|
|
45
|
+
dispatchEvent(event: Event): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Get the current host UI state and a `subscribe` function for future changes.
|
|
48
|
+
*
|
|
49
|
+
* The snapshot is fetched once at {@link EmbeddingViewSDK.create} and refreshed on every
|
|
50
|
+
* host push, so this returns synchronously. `subscribe(handler)` registers the handler for
|
|
51
|
+
* every subsequent push and returns an `unsubscribe` that detaches just that handler; the
|
|
52
|
+
* underlying wire subscription is session-scoped and shared, so detaching is a local
|
|
53
|
+
* `Set.delete`, not a wire teardown.
|
|
54
|
+
*
|
|
55
|
+
* The optional `State` type parameter narrows `state` and the `subscribe` handler for this
|
|
56
|
+
* caller; it is erased at runtime, so the stored snapshot and listeners are the open-shaped
|
|
57
|
+
* {@link UiState} and the narrowed handler is adapted to that at the boundary.
|
|
58
|
+
*
|
|
59
|
+
* @returns `{ state, subscribe }` — the latest cached snapshot and a subscribe function
|
|
60
|
+
* whose return value is the per-handler `unsubscribe`.
|
|
61
|
+
*/
|
|
62
|
+
getUiState<State extends UiState = UiState>(): {
|
|
63
|
+
state: State;
|
|
64
|
+
subscribe: (handler: (state: State) => void) => () => void;
|
|
65
|
+
};
|
|
9
66
|
markDirtyState(label?: string): Promise<void>;
|
|
10
67
|
clearDirtyState(label?: string): Promise<void>;
|
|
11
68
|
/** Resize the embedded surface. Pass `""` for either axis to leave it unchanged; both empty is a no-op. */
|
|
12
69
|
resize(width: PixelSize, height: PixelSize): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Send an event to the host over the wire. Private wire-layer plumbing; the public
|
|
72
|
+
* entry point is {@link dispatchEvent}, which calls this in addition to notifying
|
|
73
|
+
* local listeners.
|
|
74
|
+
*/
|
|
75
|
+
private dispatchHostEvent;
|
|
76
|
+
/**
|
|
77
|
+
* Open the host's event stream and pipe inbound host-pushed events onto this
|
|
78
|
+
* `EventTarget`, so `addEventListener` consumers hear them alongside same-document
|
|
79
|
+
* dispatches. Private wire-layer plumbing, opened once per session — the bridge
|
|
80
|
+
* delivers a single stream and per-type fan-out is the native `EventTarget`'s job
|
|
81
|
+
* ("one subscription per session").
|
|
82
|
+
*
|
|
83
|
+
* Inbound events are re-dispatched through `super.dispatchEvent`, not the
|
|
84
|
+
* {@link dispatchEvent} override, so a host push notifies local listeners without
|
|
85
|
+
* being echoed straight back up the wire.
|
|
86
|
+
*
|
|
87
|
+
* Best-effort: if the subscription cannot be opened, inbound host events simply do not
|
|
88
|
+
* arrive; outbound {@link dispatchEvent} and every other method still work. The wire is
|
|
89
|
+
* not explicitly torn down — it lives for the session and is released when the bridge
|
|
90
|
+
* is disposed.
|
|
91
|
+
*/
|
|
92
|
+
private subscribeToHostEvent;
|
|
93
|
+
/**
|
|
94
|
+
* Open the host's ui-state stream once per session and cache the initial snapshot,
|
|
95
|
+
* then fan out every subsequent push to registered listeners. Private wire-layer
|
|
96
|
+
* plumbing — the public entry point is {@link getUiState}.
|
|
97
|
+
*
|
|
98
|
+
* Best-effort, mirroring {@link subscribeToHostEvent}: if the subscription cannot be
|
|
99
|
+
* opened, {@link getUiState} still returns a usable (empty) snapshot and every other
|
|
100
|
+
* method continues to work. The wire is not explicitly torn down.
|
|
101
|
+
*/
|
|
102
|
+
private subscribeToUiState;
|
|
13
103
|
private setDirty;
|
|
14
104
|
}
|
|
15
105
|
//# sourceMappingURL=embedding.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedding.d.ts","sourceRoot":"","sources":["../../src/view/embedding.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"embedding.d.ts","sourceRoot":"","sources":["../../src/view/embedding.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAMhD,oHAAoH;AACpH,MAAM,MAAM,SAAS,GAAG,GAAG,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC;AAEzD;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,gBAAiB,SAAQ,WAAY,YAAW,OAAO;IAa/C,OAAO,CAAC,QAAQ,CAAC,OAAO;WAZ/B,MAAM,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAShD,OAAO,CAAC,cAAc,CAAsC;IAC5D,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAuC;IAExE,OAAO;IAIP;;;;;;;;;;;;;;;;;OAiBG;IACM,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO;IA0B7C;;;;;;;;;;;;;;;OAeG;IACH,UAAU,CAAC,KAAK,SAAS,OAAO,GAAG,OAAO,KAAK;QAC9C,KAAK,EAAE,KAAK,CAAC;QACb,SAAS,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;KAC3D;IAeK,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7C,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpD,2GAA2G;IACrG,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAYhE;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAQzB;;;;;;;;;;;;;;;OAeG;YACW,oBAAoB;IAyBlC;;;;;;;;OAQG;YACW,kBAAkB;IAiBhC,OAAO,CAAC,QAAQ;CAOhB"}
|
package/dist/view/index.d.ts
CHANGED
|
@@ -25,5 +25,5 @@ export interface ViewSDKOptions extends SDKOptions {
|
|
|
25
25
|
export declare function createViewSDK(options?: ViewSDKOptions): Promise<ViewSDK>;
|
|
26
26
|
export { MCPAppsViewSDK } from './mcpapps';
|
|
27
27
|
export { getViewSDK, getViewSDKSync, resetViewSDK } from './singleton';
|
|
28
|
-
export type { AlertOptions, ModalOptions, SDKOptions, Theme, ThemeMode, ToastOptions, ViewSDK, } from '../core';
|
|
28
|
+
export type { AlertOptions, ModalOptions, SDKOptions, Theme, ThemeMode, ToastOptions, UiState, UiStyles, ViewSDK, } from '../core';
|
|
29
29
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/view/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/view/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAKnD;;;;;;GAMG;AAEH,MAAM,WAAW,cAAe,SAAQ,UAAU;CAAG;AAErD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAgCxE;AAED,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEvE,YAAY,EACX,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,KAAK,EACL,SAAS,EACT,YAAY,EACZ,OAAO,GACP,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/view/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAKnD;;;;;;GAMG;AAEH,MAAM,WAAW,cAAe,SAAQ,UAAU;CAAG;AAErD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAgCxE;AAED,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEvE,YAAY,EACX,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,KAAK,EACL,SAAS,EACT,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,OAAO,GACP,MAAM,SAAS,CAAC"}
|
package/dist/view/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { g as
|
|
2
|
-
import { w as
|
|
3
|
-
import { requireSharedSession as
|
|
4
|
-
function
|
|
5
|
-
switch (
|
|
1
|
+
import { g as h, S as n, a as w } from "../surface-Dd2tqrPi.js";
|
|
2
|
+
import { w as p } from "../sdk-promise-D0sy7OW1.js";
|
|
3
|
+
import { requireSharedSession as m } from "../sf-embedding/index.js";
|
|
4
|
+
function f(i) {
|
|
5
|
+
switch (i) {
|
|
6
6
|
case "info":
|
|
7
7
|
return "ℹ️";
|
|
8
8
|
case "success":
|
|
@@ -15,33 +15,98 @@ function p(n) {
|
|
|
15
15
|
return "ℹ️";
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
function u(
|
|
19
|
-
return `${
|
|
18
|
+
function u(i, e) {
|
|
19
|
+
return `${f(e)} ${i}`;
|
|
20
20
|
}
|
|
21
|
-
function o(
|
|
22
|
-
const
|
|
23
|
-
if (
|
|
21
|
+
function o(i, e) {
|
|
22
|
+
const s = i.trim();
|
|
23
|
+
if (s === "")
|
|
24
24
|
return { success: !0, value: void 0 };
|
|
25
|
-
const
|
|
26
|
-
if (!
|
|
25
|
+
const t = s.match(/^(\d+(?:\.\d+)?)(px)?$/);
|
|
26
|
+
if (!t || !t[1])
|
|
27
27
|
return {
|
|
28
28
|
success: !1,
|
|
29
|
-
error: `Invalid ${e}: "${
|
|
29
|
+
error: `Invalid ${e}: "${i}". Only pixel values are supported (e.g., "800px" or "800").`
|
|
30
30
|
};
|
|
31
|
-
const r = parseFloat(
|
|
31
|
+
const r = parseFloat(t[1]);
|
|
32
32
|
return r < 0 || !isFinite(r) ? {
|
|
33
33
|
success: !1,
|
|
34
|
-
error: `Invalid ${e}: "${
|
|
34
|
+
error: `Invalid ${e}: "${i}". Value must be a positive number.`
|
|
35
35
|
} : { success: !0, value: r };
|
|
36
36
|
}
|
|
37
|
-
const
|
|
38
|
-
class l {
|
|
37
|
+
const b = "trackdirtystate";
|
|
38
|
+
class l extends EventTarget {
|
|
39
39
|
constructor(e) {
|
|
40
|
-
this.session = e;
|
|
40
|
+
super(), this.session = e;
|
|
41
41
|
}
|
|
42
42
|
static async create() {
|
|
43
|
-
const e = await
|
|
44
|
-
return
|
|
43
|
+
const e = await m("EmbeddingViewSDK"), s = new l(e);
|
|
44
|
+
return await Promise.all([s.subscribeToHostEvent(), s.subscribeToUiState()]), s;
|
|
45
|
+
}
|
|
46
|
+
// Latest snapshot, refreshed on every host push. Session-scoped — the wire subscription
|
|
47
|
+
// is opened once at create() and never torn down.
|
|
48
|
+
currentUiState = { props: {}, styles: {} };
|
|
49
|
+
uiStateListeners = /* @__PURE__ */ new Set();
|
|
50
|
+
/**
|
|
51
|
+
* Dispatch a custom event.
|
|
52
|
+
*
|
|
53
|
+
* Overrides {@link EventTarget.dispatchEvent} to be symmetric across both channels an
|
|
54
|
+
* embedded bundle can reach: it forwards the event to the host over the wire **and**
|
|
55
|
+
* notifies local listeners on this `EventTarget`. A {@link CustomEvent}'s `detail` is
|
|
56
|
+
* the payload sent to the host; a plain `Event` (no `detail`) is delivered to local
|
|
57
|
+
* listeners only, since there is nothing to carry over the wire.
|
|
58
|
+
*
|
|
59
|
+
* A bundle's own dispatch reaches its own listeners exactly once — synchronously, here
|
|
60
|
+
* — and is not echoed back: the host does not relay a bundle's own dispatch down the
|
|
61
|
+
* wire to the originating iframe (inbound re-dispatch goes through `super.dispatchEvent`,
|
|
62
|
+
* never back out through this override).
|
|
63
|
+
*
|
|
64
|
+
* @param event - The event to dispatch. Use a {@link CustomEvent} to carry a payload.
|
|
65
|
+
* @returns `false` if the event is cancelable and a listener called `preventDefault()`,
|
|
66
|
+
* otherwise `true` (native {@link EventTarget} semantics).
|
|
67
|
+
*/
|
|
68
|
+
dispatchEvent(e) {
|
|
69
|
+
if (e instanceof CustomEvent)
|
|
70
|
+
try {
|
|
71
|
+
this.dispatchHostEvent(e.type, e.detail, {
|
|
72
|
+
bubbles: e.bubbles,
|
|
73
|
+
composed: e.composed,
|
|
74
|
+
cancelable: e.cancelable
|
|
75
|
+
});
|
|
76
|
+
} catch (s) {
|
|
77
|
+
console.warn(
|
|
78
|
+
`[EmbeddingViewSDK] wire dispatch failed for "${e.type}"; local listeners will still fire`,
|
|
79
|
+
s
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
return super.dispatchEvent(e);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Get the current host UI state and a `subscribe` function for future changes.
|
|
86
|
+
*
|
|
87
|
+
* The snapshot is fetched once at {@link EmbeddingViewSDK.create} and refreshed on every
|
|
88
|
+
* host push, so this returns synchronously. `subscribe(handler)` registers the handler for
|
|
89
|
+
* every subsequent push and returns an `unsubscribe` that detaches just that handler; the
|
|
90
|
+
* underlying wire subscription is session-scoped and shared, so detaching is a local
|
|
91
|
+
* `Set.delete`, not a wire teardown.
|
|
92
|
+
*
|
|
93
|
+
* The optional `State` type parameter narrows `state` and the `subscribe` handler for this
|
|
94
|
+
* caller; it is erased at runtime, so the stored snapshot and listeners are the open-shaped
|
|
95
|
+
* {@link UiState} and the narrowed handler is adapted to that at the boundary.
|
|
96
|
+
*
|
|
97
|
+
* @returns `{ state, subscribe }` — the latest cached snapshot and a subscribe function
|
|
98
|
+
* whose return value is the per-handler `unsubscribe`.
|
|
99
|
+
*/
|
|
100
|
+
getUiState() {
|
|
101
|
+
return {
|
|
102
|
+
state: this.currentUiState,
|
|
103
|
+
subscribe: (e) => {
|
|
104
|
+
const s = e;
|
|
105
|
+
return this.uiStateListeners.add(s), () => {
|
|
106
|
+
this.uiStateListeners.delete(s);
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
};
|
|
45
110
|
}
|
|
46
111
|
async markDirtyState(e) {
|
|
47
112
|
this.setDirty(!0, e);
|
|
@@ -50,25 +115,95 @@ class l {
|
|
|
50
115
|
this.setDirty(!1, e);
|
|
51
116
|
}
|
|
52
117
|
/** Resize the embedded surface. Pass `""` for either axis to leave it unchanged; both empty is a no-op. */
|
|
53
|
-
async resize(e,
|
|
54
|
-
const
|
|
55
|
-
if (!
|
|
56
|
-
const r = o(
|
|
118
|
+
async resize(e, s) {
|
|
119
|
+
const t = o(e, "width");
|
|
120
|
+
if (!t.success) throw new Error(t.error);
|
|
121
|
+
const r = o(s, "height");
|
|
57
122
|
if (!r.success) throw new Error(r.error);
|
|
58
|
-
|
|
59
|
-
...
|
|
123
|
+
t.value === void 0 && r.value === void 0 || this.session.bridge.sendResize({
|
|
124
|
+
...t.value !== void 0 ? { width: t.value } : {},
|
|
60
125
|
...r.value !== void 0 ? { height: r.value } : {}
|
|
61
126
|
});
|
|
62
127
|
}
|
|
63
|
-
|
|
64
|
-
|
|
128
|
+
/**
|
|
129
|
+
* Send an event to the host over the wire. Private wire-layer plumbing; the public
|
|
130
|
+
* entry point is {@link dispatchEvent}, which calls this in addition to notifying
|
|
131
|
+
* local listeners.
|
|
132
|
+
*/
|
|
133
|
+
dispatchHostEvent(e, s, t) {
|
|
134
|
+
this.session.bridge.sendEventDispatch(e, s, t);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Open the host's event stream and pipe inbound host-pushed events onto this
|
|
138
|
+
* `EventTarget`, so `addEventListener` consumers hear them alongside same-document
|
|
139
|
+
* dispatches. Private wire-layer plumbing, opened once per session — the bridge
|
|
140
|
+
* delivers a single stream and per-type fan-out is the native `EventTarget`'s job
|
|
141
|
+
* ("one subscription per session").
|
|
142
|
+
*
|
|
143
|
+
* Inbound events are re-dispatched through `super.dispatchEvent`, not the
|
|
144
|
+
* {@link dispatchEvent} override, so a host push notifies local listeners without
|
|
145
|
+
* being echoed straight back up the wire.
|
|
146
|
+
*
|
|
147
|
+
* Best-effort: if the subscription cannot be opened, inbound host events simply do not
|
|
148
|
+
* arrive; outbound {@link dispatchEvent} and every other method still work. The wire is
|
|
149
|
+
* not explicitly torn down — it lives for the session and is released when the bridge
|
|
150
|
+
* is disposed.
|
|
151
|
+
*/
|
|
152
|
+
async subscribeToHostEvent() {
|
|
153
|
+
const e = this.session.bridge;
|
|
154
|
+
e.onEventDispatch((s) => {
|
|
155
|
+
super.dispatchEvent(
|
|
156
|
+
new CustomEvent(s.eventType, {
|
|
157
|
+
detail: s.detail,
|
|
158
|
+
bubbles: s.bubbles ?? !0,
|
|
159
|
+
composed: s.composed ?? !0,
|
|
160
|
+
cancelable: s.cancelable ?? !1
|
|
161
|
+
})
|
|
162
|
+
);
|
|
163
|
+
});
|
|
164
|
+
try {
|
|
165
|
+
await e.sendEventSubscribe();
|
|
166
|
+
} catch (s) {
|
|
167
|
+
console.warn(
|
|
168
|
+
"[EmbeddingViewSDK] host event subscription failed; inbound host events will not be delivered",
|
|
169
|
+
s
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Open the host's ui-state stream once per session and cache the initial snapshot,
|
|
175
|
+
* then fan out every subsequent push to registered listeners. Private wire-layer
|
|
176
|
+
* plumbing — the public entry point is {@link getUiState}.
|
|
177
|
+
*
|
|
178
|
+
* Best-effort, mirroring {@link subscribeToHostEvent}: if the subscription cannot be
|
|
179
|
+
* opened, {@link getUiState} still returns a usable (empty) snapshot and every other
|
|
180
|
+
* method continues to work. The wire is not explicitly torn down.
|
|
181
|
+
*/
|
|
182
|
+
async subscribeToUiState() {
|
|
183
|
+
const e = this.session.bridge;
|
|
184
|
+
e.onUiStateChanged((s) => {
|
|
185
|
+
this.currentUiState = s.current;
|
|
186
|
+
for (const t of this.uiStateListeners) t(s.current);
|
|
187
|
+
});
|
|
188
|
+
try {
|
|
189
|
+
const { current: s } = await e.sendUiStateSubscribe();
|
|
190
|
+
this.currentUiState = s;
|
|
191
|
+
} catch (s) {
|
|
192
|
+
console.warn(
|
|
193
|
+
"[EmbeddingViewSDK] ui-state subscription failed; getUiState will return an empty snapshot",
|
|
194
|
+
s
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
setDirty(e, s) {
|
|
199
|
+
this.session.bridge.sendEventDispatch(b, {
|
|
65
200
|
isDirty: e,
|
|
66
201
|
instanceId: this.session.hostMetaData.instanceId,
|
|
67
|
-
label:
|
|
202
|
+
label: s ?? ""
|
|
68
203
|
});
|
|
69
204
|
}
|
|
70
205
|
}
|
|
71
|
-
class
|
|
206
|
+
class g {
|
|
72
207
|
constructor(e) {
|
|
73
208
|
this.session = e;
|
|
74
209
|
}
|
|
@@ -77,14 +212,14 @@ class v {
|
|
|
77
212
|
* @param message - The message text
|
|
78
213
|
* @param level - The message severity level (defaults to "info")
|
|
79
214
|
*/
|
|
80
|
-
async sendMessage(e,
|
|
81
|
-
const
|
|
215
|
+
async sendMessage(e, s = "info") {
|
|
216
|
+
const t = u(e, s);
|
|
82
217
|
await this.session.request("ui/message", {
|
|
83
218
|
role: "user",
|
|
84
219
|
content: [
|
|
85
220
|
{
|
|
86
221
|
type: "text",
|
|
87
|
-
text:
|
|
222
|
+
text: t
|
|
88
223
|
}
|
|
89
224
|
]
|
|
90
225
|
});
|
|
@@ -102,25 +237,25 @@ class v {
|
|
|
102
237
|
const e = this.session.getHostContext().theme;
|
|
103
238
|
return e ? { mode: e } : null;
|
|
104
239
|
}
|
|
105
|
-
async resize(e,
|
|
106
|
-
const
|
|
107
|
-
if (!
|
|
108
|
-
return Promise.reject(new Error(
|
|
109
|
-
const r = o(
|
|
240
|
+
async resize(e, s) {
|
|
241
|
+
const t = o(e, "width");
|
|
242
|
+
if (!t.success)
|
|
243
|
+
return Promise.reject(new Error(t.error));
|
|
244
|
+
const r = o(s, "height");
|
|
110
245
|
if (!r.success)
|
|
111
246
|
return Promise.reject(new Error(r.error));
|
|
112
247
|
const c = {};
|
|
113
|
-
return
|
|
248
|
+
return t.value !== void 0 && (c.width = t.value), r.value !== void 0 && (c.height = r.value), this.session.sendNotification("ui/notifications/size-changed", c), Promise.resolve();
|
|
114
249
|
}
|
|
115
250
|
}
|
|
116
|
-
class
|
|
251
|
+
class v {
|
|
117
252
|
async displayAlert(e) {
|
|
118
|
-
const
|
|
119
|
-
await window.openai.sendFollowUpMessage({ prompt:
|
|
253
|
+
const s = e.level || "info", t = u(e.message, s);
|
|
254
|
+
await window.openai.sendFollowUpMessage({ prompt: t });
|
|
120
255
|
}
|
|
121
256
|
async displayToast(e) {
|
|
122
|
-
const
|
|
123
|
-
await window.openai.sendFollowUpMessage({ prompt:
|
|
257
|
+
const s = e.level || "info", t = u(e.message, s);
|
|
258
|
+
await window.openai.sendFollowUpMessage({ prompt: t });
|
|
124
259
|
}
|
|
125
260
|
async displayModal(e) {
|
|
126
261
|
await window.openai.requestModal({
|
|
@@ -133,31 +268,31 @@ class y {
|
|
|
133
268
|
return e ? { mode: e } : null;
|
|
134
269
|
}
|
|
135
270
|
}
|
|
136
|
-
let
|
|
137
|
-
function
|
|
138
|
-
return
|
|
271
|
+
let a = null, d = null;
|
|
272
|
+
function M(i) {
|
|
273
|
+
return a || (a = y(i).then((e) => (d = e, e))), a;
|
|
139
274
|
}
|
|
140
|
-
function
|
|
275
|
+
function T() {
|
|
141
276
|
return d;
|
|
142
277
|
}
|
|
143
|
-
function
|
|
144
|
-
|
|
278
|
+
function V() {
|
|
279
|
+
a = null, d = null;
|
|
145
280
|
}
|
|
146
|
-
function
|
|
147
|
-
return
|
|
281
|
+
function y(i) {
|
|
282
|
+
return p(
|
|
148
283
|
(async () => {
|
|
149
284
|
try {
|
|
150
|
-
switch (await
|
|
151
|
-
case
|
|
152
|
-
return new
|
|
153
|
-
case
|
|
154
|
-
case
|
|
285
|
+
switch (await h(i?.surface)) {
|
|
286
|
+
case n.OpenAI:
|
|
287
|
+
return new v();
|
|
288
|
+
case n.WebApp:
|
|
289
|
+
case n.Mosaic:
|
|
155
290
|
return {};
|
|
156
|
-
case
|
|
291
|
+
case n.MicroFrontend:
|
|
157
292
|
return await l.create();
|
|
158
|
-
case
|
|
159
|
-
const
|
|
160
|
-
return new
|
|
293
|
+
case n.MCPApps: {
|
|
294
|
+
const s = await w.getInstance();
|
|
295
|
+
return new g(s);
|
|
161
296
|
}
|
|
162
297
|
default:
|
|
163
298
|
return {};
|
|
@@ -170,9 +305,9 @@ function S(n) {
|
|
|
170
305
|
);
|
|
171
306
|
}
|
|
172
307
|
export {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
308
|
+
g as MCPAppsViewSDK,
|
|
309
|
+
y as createViewSDK,
|
|
310
|
+
M as getViewSDK,
|
|
311
|
+
T as getViewSDKSync,
|
|
312
|
+
V as resetViewSDK
|
|
178
313
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/platform-sdk",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.6.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
"@conduit-client/service-pubsub": "3.19.6",
|
|
116
116
|
"@conduit-client/service-retry": "3.19.6",
|
|
117
117
|
"@conduit-client/utils": "3.19.6",
|
|
118
|
-
"@salesforce/jsonrpc": "^11.
|
|
118
|
+
"@salesforce/jsonrpc": "^11.6.0",
|
|
119
119
|
"@salesforce/sf-embedding-bridge": "2.2.4-rc.1"
|
|
120
120
|
},
|
|
121
121
|
"peerDependencies": {
|