@salesforce/platform-sdk 11.4.7 → 11.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/core/view.d.ts +21 -22
- package/dist/core/view.d.ts.map +1 -1
- package/dist/data/index.js +1 -1
- package/dist/view/embedding.d.ts +60 -2
- package/dist/view/embedding.d.ts.map +1 -1
- package/dist/view/index.js +142 -63
- package/package.json +2 -2
package/dist/core/view.d.ts
CHANGED
|
@@ -93,6 +93,19 @@ export interface ModalOptions {
|
|
|
93
93
|
* alerts, toast notifications, modal dialogs, and managing application state. All methods
|
|
94
94
|
* are optional and may not be available depending on the runtime surface.
|
|
95
95
|
*
|
|
96
|
+
* ## Events
|
|
97
|
+
*
|
|
98
|
+
* A ViewSDK is a DOM {@link EventTarget}: the event API is the native
|
|
99
|
+
* `addEventListener` / `removeEventListener` / `dispatchEvent`. On surfaces backed by a
|
|
100
|
+
* host bridge (e.g. the embedded MicroFrontend surface), `dispatchEvent` both notifies
|
|
101
|
+
* local listeners and forwards the event to the host, and events pushed by the host are
|
|
102
|
+
* re-dispatched onto the SDK so `addEventListener` hears them too — one unified stream of
|
|
103
|
+
* host-pushed and same-document events.
|
|
104
|
+
*
|
|
105
|
+
* The `EventTarget` members are declared via {@link Partial} so that surfaces without an
|
|
106
|
+
* event bus (e.g. the WebApp/Mosaic degraded SDK, which is a bare `{}`) still satisfy the
|
|
107
|
+
* type. Feature-detect before use: `viewSDK.dispatchEvent?.(...)`.
|
|
108
|
+
*
|
|
96
109
|
* @example
|
|
97
110
|
* ```typescript
|
|
98
111
|
* const viewSDK = await createViewSDK();
|
|
@@ -103,11 +116,17 @@ export interface ModalOptions {
|
|
|
103
116
|
* level: 'success'
|
|
104
117
|
* });
|
|
105
118
|
*
|
|
119
|
+
* // Listen for events (host-pushed or same-document) and dispatch your own
|
|
120
|
+
* viewSDK.addEventListener?.('user-action', (e) => {
|
|
121
|
+
* console.log('received:', (e as CustomEvent).detail);
|
|
122
|
+
* });
|
|
123
|
+
* viewSDK.dispatchEvent?.(new CustomEvent('user-action', { detail: { action: 'click' } }));
|
|
124
|
+
*
|
|
106
125
|
* // Mark application as having unsaved changes
|
|
107
126
|
* await viewSDK.markDirtyState?.();
|
|
108
127
|
* ```
|
|
109
128
|
*/
|
|
110
|
-
export
|
|
129
|
+
export type ViewSDK = Partial<EventTarget> & {
|
|
111
130
|
/**
|
|
112
131
|
* Display an alert message in the host environment
|
|
113
132
|
*
|
|
@@ -225,26 +244,6 @@ export interface ViewSDK {
|
|
|
225
244
|
* ```
|
|
226
245
|
*/
|
|
227
246
|
clearDirtyState?(label?: string): Promise<void>;
|
|
228
|
-
/**
|
|
229
|
-
* Dispatch a custom event to the host environment
|
|
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.
|
|
233
|
-
*
|
|
234
|
-
* @param event - The event name/type to dispatch
|
|
235
|
-
* @param data - Associated event data as key-value pairs
|
|
236
|
-
* @returns Promise that resolves when the event is dispatched
|
|
237
|
-
*
|
|
238
|
-
* @example
|
|
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
247
|
/**
|
|
249
248
|
* Get UI properties from the host and subscribe to changes
|
|
250
249
|
*
|
|
@@ -310,5 +309,5 @@ export interface ViewSDK {
|
|
|
310
309
|
* ```
|
|
311
310
|
*/
|
|
312
311
|
getTheme?(): Theme | null;
|
|
313
|
-
}
|
|
312
|
+
};
|
|
314
313
|
//# 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,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
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,MAAM,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG;IAC5C;;;;;;;;;;;;;;;;OAgBG;IACH,YAAY,CAAC,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpD;;;;;;;;;;;;;;;;;OAiBG;IACH,YAAY,CAAC,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpD;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,YAAY,CAAC,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpD;;;;;;;;;;;;;;OAcG;IACH,UAAU,CAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;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;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,UAAU,CAAC,IAAI;QACd,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QACxC,SAAS,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,KAAK,IAAI,CAAC;KACxE,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.5.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,73 @@
|
|
|
1
1
|
import { 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>;
|
|
8
24
|
private constructor();
|
|
25
|
+
/**
|
|
26
|
+
* Dispatch a custom event.
|
|
27
|
+
*
|
|
28
|
+
* Overrides {@link EventTarget.dispatchEvent} to be symmetric across both channels an
|
|
29
|
+
* embedded bundle can reach: it forwards the event to the host over the wire **and**
|
|
30
|
+
* notifies local listeners on this `EventTarget`. A {@link CustomEvent}'s `detail` is
|
|
31
|
+
* the payload sent to the host; a plain `Event` (no `detail`) is delivered to local
|
|
32
|
+
* listeners only, since there is nothing to carry over the wire.
|
|
33
|
+
*
|
|
34
|
+
* A bundle's own dispatch reaches its own listeners exactly once — synchronously, here
|
|
35
|
+
* — and is not echoed back: the host does not relay a bundle's own dispatch down the
|
|
36
|
+
* wire to the originating iframe (inbound re-dispatch goes through `super.dispatchEvent`,
|
|
37
|
+
* never back out through this override).
|
|
38
|
+
*
|
|
39
|
+
* @param event - The event to dispatch. Use a {@link CustomEvent} to carry a payload.
|
|
40
|
+
* @returns `false` if the event is cancelable and a listener called `preventDefault()`,
|
|
41
|
+
* otherwise `true` (native {@link EventTarget} semantics).
|
|
42
|
+
*/
|
|
43
|
+
dispatchEvent(event: Event): boolean;
|
|
9
44
|
markDirtyState(label?: string): Promise<void>;
|
|
10
45
|
clearDirtyState(label?: string): Promise<void>;
|
|
11
46
|
/** Resize the embedded surface. Pass `""` for either axis to leave it unchanged; both empty is a no-op. */
|
|
12
47
|
resize(width: PixelSize, height: PixelSize): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Send an event to the host over the wire. Private wire-layer plumbing; the public
|
|
50
|
+
* entry point is {@link dispatchEvent}, which calls this in addition to notifying
|
|
51
|
+
* local listeners.
|
|
52
|
+
*/
|
|
53
|
+
private dispatchHostEvent;
|
|
54
|
+
/**
|
|
55
|
+
* Open the host's event stream and pipe inbound host-pushed events onto this
|
|
56
|
+
* `EventTarget`, so `addEventListener` consumers hear them alongside same-document
|
|
57
|
+
* dispatches. Private wire-layer plumbing, opened once per session — the bridge
|
|
58
|
+
* delivers a single stream and per-type fan-out is the native `EventTarget`'s job
|
|
59
|
+
* ("one subscription per session").
|
|
60
|
+
*
|
|
61
|
+
* Inbound events are re-dispatched through `super.dispatchEvent`, not the
|
|
62
|
+
* {@link dispatchEvent} override, so a host push notifies local listeners without
|
|
63
|
+
* being echoed straight back up the wire.
|
|
64
|
+
*
|
|
65
|
+
* Best-effort: if the subscription cannot be opened, inbound host events simply do not
|
|
66
|
+
* arrive; outbound {@link dispatchEvent} and every other method still work. The wire is
|
|
67
|
+
* not explicitly torn down — it lives for the session and is released when the bridge
|
|
68
|
+
* is disposed.
|
|
69
|
+
*/
|
|
70
|
+
private subscribeToHostEvent;
|
|
13
71
|
private setDirty;
|
|
14
72
|
}
|
|
15
73
|
//# 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;AAMvC,oHAAoH;AACpH,MAAM,MAAM,SAAS,GAAG,GAAG,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC;AAEzD
|
|
1
|
+
{"version":3,"file":"embedding.d.ts","sourceRoot":"","sources":["../../src/view/embedding.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAMvC,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;IAQ/C,OAAO,CAAC,QAAQ,CAAC,OAAO;WAP/B,MAAM,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAOhD,OAAO;IAIP;;;;;;;;;;;;;;;;;OAiBG;IACM,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO;IA0BvC,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,OAAO,CAAC,QAAQ;CAOhB"}
|
package/dist/view/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { g as
|
|
2
|
-
import { w
|
|
3
|
-
import { requireSharedSession as
|
|
4
|
-
function
|
|
1
|
+
import { g as h, S as i, a as p } from "../surface-Dd2tqrPi.js";
|
|
2
|
+
import { w } from "../sdk-promise-D0sy7OW1.js";
|
|
3
|
+
import { requireSharedSession as m } from "../sf-embedding/index.js";
|
|
4
|
+
function f(n) {
|
|
5
5
|
switch (n) {
|
|
6
6
|
case "info":
|
|
7
7
|
return "ℹ️";
|
|
@@ -15,33 +15,67 @@ function p(n) {
|
|
|
15
15
|
return "ℹ️";
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
return `${
|
|
18
|
+
function l(n, e) {
|
|
19
|
+
return `${f(e)} ${n}`;
|
|
20
20
|
}
|
|
21
21
|
function o(n, e) {
|
|
22
|
-
const
|
|
23
|
-
if (
|
|
22
|
+
const s = n.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
29
|
error: `Invalid ${e}: "${n}". 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
34
|
error: `Invalid ${e}: "${n}". Value must be a positive number.`
|
|
35
35
|
} : { success: !0, value: r };
|
|
36
36
|
}
|
|
37
|
-
const
|
|
38
|
-
class
|
|
37
|
+
const v = "trackdirtystate";
|
|
38
|
+
class u 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 u(e);
|
|
44
|
+
return await s.subscribeToHostEvent(), s;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Dispatch a custom event.
|
|
48
|
+
*
|
|
49
|
+
* Overrides {@link EventTarget.dispatchEvent} to be symmetric across both channels an
|
|
50
|
+
* embedded bundle can reach: it forwards the event to the host over the wire **and**
|
|
51
|
+
* notifies local listeners on this `EventTarget`. A {@link CustomEvent}'s `detail` is
|
|
52
|
+
* the payload sent to the host; a plain `Event` (no `detail`) is delivered to local
|
|
53
|
+
* listeners only, since there is nothing to carry over the wire.
|
|
54
|
+
*
|
|
55
|
+
* A bundle's own dispatch reaches its own listeners exactly once — synchronously, here
|
|
56
|
+
* — and is not echoed back: the host does not relay a bundle's own dispatch down the
|
|
57
|
+
* wire to the originating iframe (inbound re-dispatch goes through `super.dispatchEvent`,
|
|
58
|
+
* never back out through this override).
|
|
59
|
+
*
|
|
60
|
+
* @param event - The event to dispatch. Use a {@link CustomEvent} to carry a payload.
|
|
61
|
+
* @returns `false` if the event is cancelable and a listener called `preventDefault()`,
|
|
62
|
+
* otherwise `true` (native {@link EventTarget} semantics).
|
|
63
|
+
*/
|
|
64
|
+
dispatchEvent(e) {
|
|
65
|
+
if (e instanceof CustomEvent)
|
|
66
|
+
try {
|
|
67
|
+
this.dispatchHostEvent(e.type, e.detail, {
|
|
68
|
+
bubbles: e.bubbles,
|
|
69
|
+
composed: e.composed,
|
|
70
|
+
cancelable: e.cancelable
|
|
71
|
+
});
|
|
72
|
+
} catch (s) {
|
|
73
|
+
console.warn(
|
|
74
|
+
`[EmbeddingViewSDK] wire dispatch failed for "${e.type}"; local listeners will still fire`,
|
|
75
|
+
s
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
return super.dispatchEvent(e);
|
|
45
79
|
}
|
|
46
80
|
async markDirtyState(e) {
|
|
47
81
|
this.setDirty(!0, e);
|
|
@@ -50,25 +84,70 @@ class l {
|
|
|
50
84
|
this.setDirty(!1, e);
|
|
51
85
|
}
|
|
52
86
|
/** 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(
|
|
87
|
+
async resize(e, s) {
|
|
88
|
+
const t = o(e, "width");
|
|
89
|
+
if (!t.success) throw new Error(t.error);
|
|
90
|
+
const r = o(s, "height");
|
|
57
91
|
if (!r.success) throw new Error(r.error);
|
|
58
|
-
|
|
59
|
-
...
|
|
92
|
+
t.value === void 0 && r.value === void 0 || this.session.bridge.sendResize({
|
|
93
|
+
...t.value !== void 0 ? { width: t.value } : {},
|
|
60
94
|
...r.value !== void 0 ? { height: r.value } : {}
|
|
61
95
|
});
|
|
62
96
|
}
|
|
63
|
-
|
|
64
|
-
|
|
97
|
+
/**
|
|
98
|
+
* Send an event to the host over the wire. Private wire-layer plumbing; the public
|
|
99
|
+
* entry point is {@link dispatchEvent}, which calls this in addition to notifying
|
|
100
|
+
* local listeners.
|
|
101
|
+
*/
|
|
102
|
+
dispatchHostEvent(e, s, t) {
|
|
103
|
+
this.session.bridge.sendEventDispatch(e, s, t);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Open the host's event stream and pipe inbound host-pushed events onto this
|
|
107
|
+
* `EventTarget`, so `addEventListener` consumers hear them alongside same-document
|
|
108
|
+
* dispatches. Private wire-layer plumbing, opened once per session — the bridge
|
|
109
|
+
* delivers a single stream and per-type fan-out is the native `EventTarget`'s job
|
|
110
|
+
* ("one subscription per session").
|
|
111
|
+
*
|
|
112
|
+
* Inbound events are re-dispatched through `super.dispatchEvent`, not the
|
|
113
|
+
* {@link dispatchEvent} override, so a host push notifies local listeners without
|
|
114
|
+
* being echoed straight back up the wire.
|
|
115
|
+
*
|
|
116
|
+
* Best-effort: if the subscription cannot be opened, inbound host events simply do not
|
|
117
|
+
* arrive; outbound {@link dispatchEvent} and every other method still work. The wire is
|
|
118
|
+
* not explicitly torn down — it lives for the session and is released when the bridge
|
|
119
|
+
* is disposed.
|
|
120
|
+
*/
|
|
121
|
+
async subscribeToHostEvent() {
|
|
122
|
+
const e = this.session.bridge;
|
|
123
|
+
e.onEventDispatch((s) => {
|
|
124
|
+
super.dispatchEvent(
|
|
125
|
+
new CustomEvent(s.eventType, {
|
|
126
|
+
detail: s.detail,
|
|
127
|
+
bubbles: s.bubbles ?? !0,
|
|
128
|
+
composed: s.composed ?? !0,
|
|
129
|
+
cancelable: s.cancelable ?? !1
|
|
130
|
+
})
|
|
131
|
+
);
|
|
132
|
+
});
|
|
133
|
+
try {
|
|
134
|
+
await e.sendEventSubscribe();
|
|
135
|
+
} catch (s) {
|
|
136
|
+
console.warn(
|
|
137
|
+
"[EmbeddingViewSDK] host event subscription failed; inbound host events will not be delivered",
|
|
138
|
+
s
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
setDirty(e, s) {
|
|
143
|
+
this.session.bridge.sendEventDispatch(v, {
|
|
65
144
|
isDirty: e,
|
|
66
145
|
instanceId: this.session.hostMetaData.instanceId,
|
|
67
|
-
label:
|
|
146
|
+
label: s ?? ""
|
|
68
147
|
});
|
|
69
148
|
}
|
|
70
149
|
}
|
|
71
|
-
class
|
|
150
|
+
class g {
|
|
72
151
|
constructor(e) {
|
|
73
152
|
this.session = e;
|
|
74
153
|
}
|
|
@@ -77,14 +156,14 @@ class v {
|
|
|
77
156
|
* @param message - The message text
|
|
78
157
|
* @param level - The message severity level (defaults to "info")
|
|
79
158
|
*/
|
|
80
|
-
async sendMessage(e,
|
|
81
|
-
const
|
|
159
|
+
async sendMessage(e, s = "info") {
|
|
160
|
+
const t = l(e, s);
|
|
82
161
|
await this.session.request("ui/message", {
|
|
83
162
|
role: "user",
|
|
84
163
|
content: [
|
|
85
164
|
{
|
|
86
165
|
type: "text",
|
|
87
|
-
text:
|
|
166
|
+
text: t
|
|
88
167
|
}
|
|
89
168
|
]
|
|
90
169
|
});
|
|
@@ -102,25 +181,25 @@ class v {
|
|
|
102
181
|
const e = this.session.getHostContext().theme;
|
|
103
182
|
return e ? { mode: e } : null;
|
|
104
183
|
}
|
|
105
|
-
async resize(e,
|
|
106
|
-
const
|
|
107
|
-
if (!
|
|
108
|
-
return Promise.reject(new Error(
|
|
109
|
-
const r = o(
|
|
184
|
+
async resize(e, s) {
|
|
185
|
+
const t = o(e, "width");
|
|
186
|
+
if (!t.success)
|
|
187
|
+
return Promise.reject(new Error(t.error));
|
|
188
|
+
const r = o(s, "height");
|
|
110
189
|
if (!r.success)
|
|
111
190
|
return Promise.reject(new Error(r.error));
|
|
112
191
|
const c = {};
|
|
113
|
-
return
|
|
192
|
+
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
193
|
}
|
|
115
194
|
}
|
|
116
|
-
class
|
|
195
|
+
class b {
|
|
117
196
|
async displayAlert(e) {
|
|
118
|
-
const
|
|
119
|
-
await window.openai.sendFollowUpMessage({ prompt:
|
|
197
|
+
const s = e.level || "info", t = l(e.message, s);
|
|
198
|
+
await window.openai.sendFollowUpMessage({ prompt: t });
|
|
120
199
|
}
|
|
121
200
|
async displayToast(e) {
|
|
122
|
-
const
|
|
123
|
-
await window.openai.sendFollowUpMessage({ prompt:
|
|
201
|
+
const s = e.level || "info", t = l(e.message, s);
|
|
202
|
+
await window.openai.sendFollowUpMessage({ prompt: t });
|
|
124
203
|
}
|
|
125
204
|
async displayModal(e) {
|
|
126
205
|
await window.openai.requestModal({
|
|
@@ -133,31 +212,31 @@ class y {
|
|
|
133
212
|
return e ? { mode: e } : null;
|
|
134
213
|
}
|
|
135
214
|
}
|
|
136
|
-
let
|
|
137
|
-
function
|
|
138
|
-
return
|
|
215
|
+
let a = null, d = null;
|
|
216
|
+
function M(n) {
|
|
217
|
+
return a || (a = y(n).then((e) => (d = e, e))), a;
|
|
139
218
|
}
|
|
140
|
-
function
|
|
219
|
+
function T() {
|
|
141
220
|
return d;
|
|
142
221
|
}
|
|
143
|
-
function
|
|
144
|
-
|
|
222
|
+
function V() {
|
|
223
|
+
a = null, d = null;
|
|
145
224
|
}
|
|
146
|
-
function
|
|
147
|
-
return
|
|
225
|
+
function y(n) {
|
|
226
|
+
return w(
|
|
148
227
|
(async () => {
|
|
149
228
|
try {
|
|
150
|
-
switch (await
|
|
151
|
-
case
|
|
152
|
-
return new
|
|
153
|
-
case
|
|
154
|
-
case
|
|
229
|
+
switch (await h(n?.surface)) {
|
|
230
|
+
case i.OpenAI:
|
|
231
|
+
return new b();
|
|
232
|
+
case i.WebApp:
|
|
233
|
+
case i.Mosaic:
|
|
155
234
|
return {};
|
|
156
|
-
case
|
|
157
|
-
return await
|
|
158
|
-
case
|
|
159
|
-
const
|
|
160
|
-
return new
|
|
235
|
+
case i.MicroFrontend:
|
|
236
|
+
return await u.create();
|
|
237
|
+
case i.MCPApps: {
|
|
238
|
+
const s = await p.getInstance();
|
|
239
|
+
return new g(s);
|
|
161
240
|
}
|
|
162
241
|
default:
|
|
163
242
|
return {};
|
|
@@ -170,9 +249,9 @@ function S(n) {
|
|
|
170
249
|
);
|
|
171
250
|
}
|
|
172
251
|
export {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
252
|
+
g as MCPAppsViewSDK,
|
|
253
|
+
y as createViewSDK,
|
|
254
|
+
M as getViewSDK,
|
|
255
|
+
T as getViewSDKSync,
|
|
256
|
+
V as resetViewSDK
|
|
178
257
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/platform-sdk",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.5.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.5.0",
|
|
119
119
|
"@salesforce/sf-embedding-bridge": "2.2.4-rc.1"
|
|
120
120
|
},
|
|
121
121
|
"peerDependencies": {
|