@salesforce/platform-sdk 11.4.6 → 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.
@@ -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 interface ViewSDK {
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
@@ -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,O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H,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"}
@@ -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.4.6", de = (t) => {
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";
@@ -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
- /** ViewSDK for the sf-embedding surface; wraps bridge wire-layer primitives. */
5
- export declare class EmbeddingViewSDK implements ViewSDK {
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,G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iB;IAQzB;;;;;;;;;;;;;;;OAeG;YACW,oBAAoB;IAyBlC,OAAO,CAAC,QAAQ;CAOhB"}
@@ -1,7 +1,7 @@
1
- import { g as w, S as a, a as h } from "../surface-Dd2tqrPi.js";
2
- import { w as m } from "../sdk-promise-D0sy7OW1.js";
3
- import { requireSharedSession as f } from "../sf-embedding/index.js";
4
- function p(n) {
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 u(n, e) {
19
- return `${p(e)} ${n}`;
18
+ function l(n, e) {
19
+ return `${f(e)} ${n}`;
20
20
  }
21
21
  function o(n, e) {
22
- const t = n.trim();
23
- if (t === "")
22
+ const s = n.trim();
23
+ if (s === "")
24
24
  return { success: !0, value: void 0 };
25
- const s = t.match(/^(\d+(?:\.\d+)?)(px)?$/);
26
- if (!s || !s[1])
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(s[1]);
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 g = "trackdirtystate";
38
- class l {
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 f("EmbeddingViewSDK");
44
- return new l(e);
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, t) {
54
- const s = o(e, "width");
55
- if (!s.success) throw new Error(s.error);
56
- const r = o(t, "height");
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
- s.value === void 0 && r.value === void 0 || this.session.bridge.sendResize({
59
- ...s.value !== void 0 ? { width: s.value } : {},
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
- setDirty(e, t) {
64
- this.session.bridge.sendEventDispatch(g, {
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: t ?? ""
146
+ label: s ?? ""
68
147
  });
69
148
  }
70
149
  }
71
- class v {
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, t = "info") {
81
- const s = u(e, t);
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: s
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, t) {
106
- const s = o(e, "width");
107
- if (!s.success)
108
- return Promise.reject(new Error(s.error));
109
- const r = o(t, "height");
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 s.value !== void 0 && (c.width = s.value), r.value !== void 0 && (c.height = r.value), this.session.sendNotification("ui/notifications/size-changed", c), Promise.resolve();
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 y {
195
+ class b {
117
196
  async displayAlert(e) {
118
- const t = e.level || "info", s = u(e.message, t);
119
- await window.openai.sendFollowUpMessage({ prompt: s });
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 t = e.level || "info", s = u(e.message, t);
123
- await window.openai.sendFollowUpMessage({ prompt: s });
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 i = null, d = null;
137
- function A(n) {
138
- return i || (i = S(n).then((e) => (d = e, e))), i;
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 E() {
219
+ function T() {
141
220
  return d;
142
221
  }
143
- function I() {
144
- i = null, d = null;
222
+ function V() {
223
+ a = null, d = null;
145
224
  }
146
- function S(n) {
147
- return m(
225
+ function y(n) {
226
+ return w(
148
227
  (async () => {
149
228
  try {
150
- switch (await w(n?.surface)) {
151
- case a.OpenAI:
152
- return new y();
153
- case a.WebApp:
154
- case a.Mosaic:
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 a.MicroFrontend:
157
- return await l.create();
158
- case a.MCPApps: {
159
- const t = await h.getInstance();
160
- return new v(t);
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
- v as MCPAppsViewSDK,
174
- S as createViewSDK,
175
- A as getViewSDK,
176
- E as getViewSDKSync,
177
- I as resetViewSDK
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.4.6",
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.4.6",
118
+ "@salesforce/jsonrpc": "^11.5.0",
119
119
  "@salesforce/sf-embedding-bridge": "2.2.4-rc.1"
120
120
  },
121
121
  "peerDependencies": {