@salesforce/platform-sdk 11.5.0 → 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 +65 -19
- package/dist/core/view.d.ts.map +1 -1
- package/dist/data/index.js +1 -1
- package/dist/view/embedding.d.ts +33 -1
- 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 +88 -32
- 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
|
*/
|
|
@@ -245,32 +273,50 @@ export type ViewSDK = Partial<EventTarget> & {
|
|
|
245
273
|
*/
|
|
246
274
|
clearDirtyState?(label?: string): Promise<void>;
|
|
247
275
|
/**
|
|
248
|
-
* Get
|
|
276
|
+
* Get the current host UI state and a `subscribe` function for future changes.
|
|
249
277
|
*
|
|
250
|
-
* Returns
|
|
251
|
-
*
|
|
252
|
-
*
|
|
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.
|
|
253
283
|
*
|
|
254
|
-
*
|
|
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.
|
|
290
|
+
*
|
|
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`.
|
|
255
294
|
*
|
|
256
295
|
* @example
|
|
257
296
|
* ```typescript
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
*
|
|
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
|
|
269
315
|
* ```
|
|
270
316
|
*/
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
subscribe: (
|
|
317
|
+
getUiState?<State extends UiState = UiState>(): {
|
|
318
|
+
state: State;
|
|
319
|
+
subscribe: (handler: (state: State) => void) => () => void;
|
|
274
320
|
};
|
|
275
321
|
/**
|
|
276
322
|
* Resize the application viewport
|
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,IAAI,EAAE,SAAS,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC5B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;CACrB;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC5B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;CACrB;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC5B;;;;;;;;OAQG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED;;;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;IAExC;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,cAAc,CAAC,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/C;;;;;;;;;;;;;;;;;;OAkBG;IACH,eAAe,CAAC,CAAC,KAAK,CAAC,EAAE,MAAM,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,4 +1,4 @@
|
|
|
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
4
|
/**
|
|
@@ -21,6 +21,8 @@ export type PixelSize = `${number}` | `${number}px` | "";
|
|
|
21
21
|
export declare class EmbeddingViewSDK extends EventTarget implements ViewSDK {
|
|
22
22
|
private readonly session;
|
|
23
23
|
static create(): Promise<EmbeddingViewSDK>;
|
|
24
|
+
private currentUiState;
|
|
25
|
+
private readonly uiStateListeners;
|
|
24
26
|
private constructor();
|
|
25
27
|
/**
|
|
26
28
|
* Dispatch a custom event.
|
|
@@ -41,6 +43,26 @@ export declare class EmbeddingViewSDK extends EventTarget implements ViewSDK {
|
|
|
41
43
|
* otherwise `true` (native {@link EventTarget} semantics).
|
|
42
44
|
*/
|
|
43
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
|
+
};
|
|
44
66
|
markDirtyState(label?: string): Promise<void>;
|
|
45
67
|
clearDirtyState(label?: string): Promise<void>;
|
|
46
68
|
/** Resize the embedded surface. Pass `""` for either axis to leave it unchanged; both empty is a no-op. */
|
|
@@ -68,6 +90,16 @@ export declare class EmbeddingViewSDK extends EventTarget implements ViewSDK {
|
|
|
68
90
|
* is disposed.
|
|
69
91
|
*/
|
|
70
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;
|
|
71
103
|
private setDirty;
|
|
72
104
|
}
|
|
73
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 h, S as
|
|
2
|
-
import { w } from "../sdk-promise-D0sy7OW1.js";
|
|
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
3
|
import { requireSharedSession as m } from "../sf-embedding/index.js";
|
|
4
|
-
function f(
|
|
5
|
-
switch (
|
|
4
|
+
function f(i) {
|
|
5
|
+
switch (i) {
|
|
6
6
|
case "info":
|
|
7
7
|
return "ℹ️";
|
|
8
8
|
case "success":
|
|
@@ -15,34 +15,38 @@ function f(n) {
|
|
|
15
15
|
return "ℹ️";
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
return `${f(e)} ${
|
|
18
|
+
function u(i, e) {
|
|
19
|
+
return `${f(e)} ${i}`;
|
|
20
20
|
}
|
|
21
|
-
function o(
|
|
22
|
-
const s =
|
|
21
|
+
function o(i, e) {
|
|
22
|
+
const s = i.trim();
|
|
23
23
|
if (s === "")
|
|
24
24
|
return { success: !0, value: void 0 };
|
|
25
25
|
const t = s.match(/^(\d+(?:\.\d+)?)(px)?$/);
|
|
26
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
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
|
|
37
|
+
const b = "trackdirtystate";
|
|
38
|
+
class l extends EventTarget {
|
|
39
39
|
constructor(e) {
|
|
40
40
|
super(), this.session = e;
|
|
41
41
|
}
|
|
42
42
|
static async create() {
|
|
43
|
-
const e = await m("EmbeddingViewSDK"), s = new
|
|
44
|
-
return await s.subscribeToHostEvent(), s;
|
|
43
|
+
const e = await m("EmbeddingViewSDK"), s = new l(e);
|
|
44
|
+
return await Promise.all([s.subscribeToHostEvent(), s.subscribeToUiState()]), s;
|
|
45
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();
|
|
46
50
|
/**
|
|
47
51
|
* Dispatch a custom event.
|
|
48
52
|
*
|
|
@@ -77,6 +81,33 @@ class u extends EventTarget {
|
|
|
77
81
|
}
|
|
78
82
|
return super.dispatchEvent(e);
|
|
79
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
|
+
};
|
|
110
|
+
}
|
|
80
111
|
async markDirtyState(e) {
|
|
81
112
|
this.setDirty(!0, e);
|
|
82
113
|
}
|
|
@@ -139,8 +170,33 @@ class u extends EventTarget {
|
|
|
139
170
|
);
|
|
140
171
|
}
|
|
141
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
|
+
}
|
|
142
198
|
setDirty(e, s) {
|
|
143
|
-
this.session.bridge.sendEventDispatch(
|
|
199
|
+
this.session.bridge.sendEventDispatch(b, {
|
|
144
200
|
isDirty: e,
|
|
145
201
|
instanceId: this.session.hostMetaData.instanceId,
|
|
146
202
|
label: s ?? ""
|
|
@@ -157,7 +213,7 @@ class g {
|
|
|
157
213
|
* @param level - The message severity level (defaults to "info")
|
|
158
214
|
*/
|
|
159
215
|
async sendMessage(e, s = "info") {
|
|
160
|
-
const t =
|
|
216
|
+
const t = u(e, s);
|
|
161
217
|
await this.session.request("ui/message", {
|
|
162
218
|
role: "user",
|
|
163
219
|
content: [
|
|
@@ -192,13 +248,13 @@ class g {
|
|
|
192
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();
|
|
193
249
|
}
|
|
194
250
|
}
|
|
195
|
-
class
|
|
251
|
+
class v {
|
|
196
252
|
async displayAlert(e) {
|
|
197
|
-
const s = e.level || "info", t =
|
|
253
|
+
const s = e.level || "info", t = u(e.message, s);
|
|
198
254
|
await window.openai.sendFollowUpMessage({ prompt: t });
|
|
199
255
|
}
|
|
200
256
|
async displayToast(e) {
|
|
201
|
-
const s = e.level || "info", t =
|
|
257
|
+
const s = e.level || "info", t = u(e.message, s);
|
|
202
258
|
await window.openai.sendFollowUpMessage({ prompt: t });
|
|
203
259
|
}
|
|
204
260
|
async displayModal(e) {
|
|
@@ -213,8 +269,8 @@ class b {
|
|
|
213
269
|
}
|
|
214
270
|
}
|
|
215
271
|
let a = null, d = null;
|
|
216
|
-
function M(
|
|
217
|
-
return a || (a = y(
|
|
272
|
+
function M(i) {
|
|
273
|
+
return a || (a = y(i).then((e) => (d = e, e))), a;
|
|
218
274
|
}
|
|
219
275
|
function T() {
|
|
220
276
|
return d;
|
|
@@ -222,20 +278,20 @@ function T() {
|
|
|
222
278
|
function V() {
|
|
223
279
|
a = null, d = null;
|
|
224
280
|
}
|
|
225
|
-
function y(
|
|
226
|
-
return
|
|
281
|
+
function y(i) {
|
|
282
|
+
return p(
|
|
227
283
|
(async () => {
|
|
228
284
|
try {
|
|
229
|
-
switch (await h(
|
|
230
|
-
case
|
|
231
|
-
return new
|
|
232
|
-
case
|
|
233
|
-
case
|
|
285
|
+
switch (await h(i?.surface)) {
|
|
286
|
+
case n.OpenAI:
|
|
287
|
+
return new v();
|
|
288
|
+
case n.WebApp:
|
|
289
|
+
case n.Mosaic:
|
|
234
290
|
return {};
|
|
235
|
-
case
|
|
236
|
-
return await
|
|
237
|
-
case
|
|
238
|
-
const s = await
|
|
291
|
+
case n.MicroFrontend:
|
|
292
|
+
return await l.create();
|
|
293
|
+
case n.MCPApps: {
|
|
294
|
+
const s = await w.getInstance();
|
|
239
295
|
return new g(s);
|
|
240
296
|
}
|
|
241
297
|
default:
|
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": {
|