@salesforce/sdk-core 1.131.3 → 1.133.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/index.d.ts CHANGED
@@ -15,6 +15,7 @@ export type { JsonRpcBase, JsonRpcRequest, JsonRpcError, JsonRpcSuccessResponse,
15
15
  export { isJsonRpcBase, isJsonRpcSuccessResponse, isJsonRpcErrorResponse, isJsonRpcResponse, isJsonRpcNotification, isJsonRpcRequest, } from './jsonrpc';
16
16
  export { JsonRpcClient, WindowPostMessageTransport } from './jsonrpc-client';
17
17
  export type { Transport } from './jsonrpc-client';
18
+ export { MessageChannelTransport, type MessageChannelTransportListener, } from './mfe-protocol/message-channel-transport';
18
19
  export { McpAppsSession } from './mcpapps-session';
19
20
  export type { McpAppsHostContext, McpAppsSessionOptions } from './mcpapps-session';
20
21
  export { getSurfaceCapabilities } from './capabilities';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGhD,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGvF,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAG5C,YAAY,EACX,WAAW,EACX,UAAU,EACV,WAAW,EACX,OAAO,EACP,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,cAAc,EACd,QAAQ,EACR,SAAS,GACT,MAAM,QAAQ,CAAC;AAGhB,YAAY,EACX,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,KAAK,EACL,SAAS,EACT,OAAO,GACP,MAAM,QAAQ,CAAC;AAGhB,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAGvE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE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", e.Mosaic = "Mosaic", e))(i || {});
2
- const d = f();
3
- function f() {
1
+ var o = /* @__PURE__ */ ((t) => (t.WebApp = "WebApp", t.MicroFrontend = "Micro-Frontend", t.OpenAI = "OpenAI", t.SalesforceACC = "Salesforce-ACC", t.MCPApps = "MCP-Apps", t.Mosaic = "Mosaic", t))(o || {});
2
+ const f = d();
3
+ function d() {
4
4
  if (typeof window > "u")
5
5
  return "Mosaic";
6
6
  if (window.openai)
@@ -11,29 +11,29 @@ function f() {
11
11
  } catch {
12
12
  return "Micro-Frontend";
13
13
  }
14
- const e = window;
15
- return e.$A || e.Aura ? "Salesforce-ACC" : "WebApp";
14
+ const t = window;
15
+ return t.$A || t.Aura ? "Salesforce-ACC" : "WebApp";
16
16
  }
17
- function S(e) {
18
- return e ?? d;
17
+ function S(t) {
18
+ return t ?? f;
19
19
  }
20
- function l(e) {
21
- return typeof e == "object" && e !== null && "jsonrpc" in e && e.jsonrpc === "2.0";
20
+ function u(t) {
21
+ return typeof t == "object" && t !== null && "jsonrpc" in t && t.jsonrpc === "2.0";
22
22
  }
23
- function p(e) {
24
- return l(e) && "id" in e && typeof e.id == "number" && "result" in e;
23
+ function h(t) {
24
+ return u(t) && "id" in t && typeof t.id == "number" && "result" in t;
25
25
  }
26
- function u(e) {
27
- return l(e) && "id" in e && typeof e.id == "number" && "error" in e;
26
+ function l(t) {
27
+ return u(t) && "id" in t && typeof t.id == "number" && "error" in t;
28
28
  }
29
- function h(e) {
30
- return p(e) || u(e);
29
+ function p(t) {
30
+ return h(t) || l(t);
31
31
  }
32
- function g(e) {
33
- return l(e) && "method" in e && typeof e.method == "string" && !("id" in e);
32
+ function g(t) {
33
+ return u(t) && "method" in t && typeof t.method == "string" && !("id" in t);
34
34
  }
35
- function b(e) {
36
- return l(e) && "id" in e && typeof e.id == "number" && "method" in e && typeof e.method == "string";
35
+ function R(t) {
36
+ return u(t) && "id" in t && typeof t.id == "number" && "method" in t && typeof t.method == "string";
37
37
  }
38
38
  class T {
39
39
  targetOrigin;
@@ -43,15 +43,15 @@ class T {
43
43
  * compatibility. Pin to the known parent origin when possible to
44
44
  * prevent leaking messages to a cross-origin navigated parent.
45
45
  */
46
- constructor(t = "*") {
47
- this.targetOrigin = t;
46
+ constructor(e = "*") {
47
+ this.targetOrigin = e;
48
48
  }
49
- post(t) {
50
- window.parent?.postMessage(t, this.targetOrigin);
49
+ post(e) {
50
+ window.parent?.postMessage(e, this.targetOrigin);
51
51
  }
52
- onMessage(t) {
52
+ onMessage(e) {
53
53
  const s = (n) => {
54
- t(n.data);
54
+ e(n.data);
55
55
  };
56
56
  return window.addEventListener("message", s), () => window.removeEventListener("message", s);
57
57
  }
@@ -68,8 +68,8 @@ class M {
68
68
  * `WindowPostMessageTransport`, which preserves the original
69
69
  * `window.parent.postMessage` behaviour.
70
70
  */
71
- constructor(t = new T()) {
72
- this.transport = t, this.transport.onMessage(this.onMessage);
71
+ constructor(e = new T()) {
72
+ this.transport = e, this.transport.onMessage(this.onMessage);
73
73
  }
74
74
  /**
75
75
  * Register a handler for a specific JSON-RPC notification method
@@ -86,8 +86,8 @@ class M {
86
86
  * this.handleHostContextChanged(params);
87
87
  * });
88
88
  */
89
- registerNotificationHandler(t, s) {
90
- this.notificationHandlers.has(t) || this.notificationHandlers.set(t, /* @__PURE__ */ new Set()), this.notificationHandlers.get(t).add(s);
89
+ registerNotificationHandler(e, s) {
90
+ this.notificationHandlers.has(e) || this.notificationHandlers.set(e, /* @__PURE__ */ new Set()), this.notificationHandlers.get(e).add(s);
91
91
  }
92
92
  /**
93
93
  * Handle inbound JSON-RPC messages from the transport.
@@ -96,17 +96,17 @@ class M {
96
96
  * payloads are silently ignored so that a shared transport can be used for
97
97
  * multiple protocols without cross-talk.
98
98
  */
99
- onMessage = (t) => {
100
- if (h(t)) {
101
- const s = this.pending.get(t.id);
99
+ onMessage = (e) => {
100
+ if (p(e)) {
101
+ const s = this.pending.get(e.id);
102
102
  if (!s)
103
103
  return;
104
- this.pending.delete(t.id), u(t) ? s.reject(new Error(t.error.message || "Request failed")) : s.resolve(t.result);
104
+ this.pending.delete(e.id), l(e) ? s.reject(new Error(e.error.message || "Request failed")) : s.resolve(e.result);
105
105
  return;
106
106
  }
107
- if (g(t)) {
108
- const s = this.notificationHandlers.get(t.method);
109
- s && s.forEach((n) => n(t.params));
107
+ if (g(e)) {
108
+ const s = this.notificationHandlers.get(e.method);
109
+ s && s.forEach((n) => n(e.params));
110
110
  }
111
111
  };
112
112
  /**
@@ -122,16 +122,16 @@ class M {
122
122
  * content: { type: "text", text: "Hello" }
123
123
  * });
124
124
  */
125
- request(t, s) {
125
+ request(e, s) {
126
126
  const n = this.nextRequestId++, r = {
127
127
  jsonrpc: "2.0",
128
128
  id: n,
129
- method: t,
129
+ method: e,
130
130
  params: s
131
131
  };
132
- return new Promise((o, c) => {
132
+ return new Promise((i, c) => {
133
133
  this.pending.set(n, {
134
- resolve: o,
134
+ resolve: i,
135
135
  reject: c
136
136
  }), this.transport.post(r);
137
137
  });
@@ -159,16 +159,114 @@ class M {
159
159
  * height: 600
160
160
  * });
161
161
  */
162
- sendNotification(t, s) {
162
+ sendNotification(e, s) {
163
163
  const n = {
164
164
  jsonrpc: "2.0",
165
- method: t,
165
+ method: e,
166
166
  params: s
167
167
  };
168
168
  this.transport.post(n);
169
169
  }
170
170
  }
171
- const C = 500, w = "2026-01-26";
171
+ function y() {
172
+ }
173
+ class H {
174
+ #e;
175
+ #s = /* @__PURE__ */ new Set();
176
+ #i = !1;
177
+ #n = !1;
178
+ /** Messages queued before `port.start()` has been called. Flushed on first subscribe. */
179
+ #t = [];
180
+ constructor(e) {
181
+ this.#e = e;
182
+ }
183
+ /**
184
+ * Post a message to the peer.
185
+ *
186
+ * Never throws on transient failure — a closed / neutered / disposed
187
+ * port silently drops the message. If the transport has not yet
188
+ * started (no `onMessage` subscriber), the message is buffered and
189
+ * flushed on first subscription.
190
+ */
191
+ post(e) {
192
+ if (!this.#n) {
193
+ if (!this.#i) {
194
+ this.#t.push(e);
195
+ return;
196
+ }
197
+ try {
198
+ this.#e.postMessage(e);
199
+ } catch {
200
+ }
201
+ }
202
+ }
203
+ /**
204
+ * Subscribe to inbound messages from the peer. The callback receives
205
+ * the **unwrapped** payload (`MessageEvent.data`) — callers never see
206
+ * the `MessageEvent` wrapper.
207
+ *
208
+ * Starts the underlying port on first subscription and flushes any
209
+ * messages queued via `post` before the port was started.
210
+ *
211
+ * Returns an unsubscribe function. Calling it is idempotent.
212
+ */
213
+ onMessage(e) {
214
+ if (this.#n)
215
+ return y;
216
+ this.#s.add(e), this.#i || this.#r();
217
+ let s = !1;
218
+ return () => {
219
+ s || (s = !0, this.#s.delete(e));
220
+ };
221
+ }
222
+ /**
223
+ * Tear down the transport:
224
+ * - remove the internal `message` listener
225
+ * - call `port.close()`
226
+ * - clear subscriber set and outbound buffer
227
+ * - subsequent `post` calls silently no-op
228
+ * - subsequent `onMessage` calls return a no-op unsubscribe
229
+ */
230
+ dispose() {
231
+ if (!this.#n) {
232
+ this.#n = !0;
233
+ try {
234
+ this.#e.removeEventListener("message", this.#o);
235
+ } catch {
236
+ }
237
+ this.#s.clear(), this.#t.length = 0;
238
+ try {
239
+ this.#e.close();
240
+ } catch {
241
+ }
242
+ }
243
+ }
244
+ #r() {
245
+ this.#i = !0, this.#e.addEventListener("message", this.#o);
246
+ try {
247
+ this.#e.start();
248
+ } catch {
249
+ }
250
+ if (this.#t.length > 0) {
251
+ const e = this.#t;
252
+ this.#t = [];
253
+ for (const s of e)
254
+ try {
255
+ this.#e.postMessage(s);
256
+ } catch {
257
+ }
258
+ }
259
+ }
260
+ #o = (e) => {
261
+ const s = [...this.#s];
262
+ for (const n of s)
263
+ try {
264
+ n(e.data);
265
+ } catch {
266
+ }
267
+ };
268
+ }
269
+ const m = 500, C = "2026-01-26";
172
270
  class a extends M {
173
271
  static initPromise = null;
174
272
  hostCtx = {};
@@ -179,10 +277,10 @@ class a extends M {
179
277
  * The first call performs the SEP-1865 handshake. Concurrent and subsequent
180
278
  * calls reuse the same session and handshake result.
181
279
  */
182
- static async getInstance(t) {
280
+ static async getInstance(e) {
183
281
  return a.initPromise || (a.initPromise = (async () => {
184
282
  const s = new a();
185
- return await s.handshake(t), s;
283
+ return await s.handshake(e), s;
186
284
  })()), a.initPromise;
187
285
  }
188
286
  /**
@@ -199,18 +297,18 @@ class a extends M {
199
297
  * On timeout or error, falls back to an empty host context so the app can
200
298
  * still render (graceful degradation for non-SEP-1865 hosts).
201
299
  */
202
- async handshake(t) {
203
- const s = t?.handshakeTimeoutMs ?? C, n = t?.appInfo ?? { name: "mcp-app", version: "1.0.0" };
300
+ async handshake(e) {
301
+ const s = e?.handshakeTimeoutMs ?? m, n = e?.appInfo ?? { name: "mcp-app", version: "1.0.0" };
204
302
  try {
205
- const r = /* @__PURE__ */ Symbol("timeout"), o = await Promise.race([
303
+ const r = /* @__PURE__ */ Symbol("timeout"), i = await Promise.race([
206
304
  this.request("ui/initialize", {
207
- protocolVersion: w,
305
+ protocolVersion: C,
208
306
  appInfo: n,
209
307
  appCapabilities: {}
210
308
  }),
211
309
  new Promise((c) => setTimeout(() => c(r), s))
212
310
  ]);
213
- o !== r && (this.hostCtx = o.hostContext ?? {}, this._handshakeSucceeded = !0, this.registerNotificationHandler("ui/notifications/host-context-changed", (c) => {
311
+ i !== r && (this.hostCtx = i.hostContext ?? {}, this._handshakeSucceeded = !0, this.registerNotificationHandler("ui/notifications/host-context-changed", (c) => {
214
312
  this.hostCtx = {
215
313
  ...this.hostCtx,
216
314
  ...c
@@ -230,17 +328,17 @@ class a extends M {
230
328
  // ── Public wrappers ──────────────────────────────────────────────────
231
329
  // Widen access from protected to public so SDK classes can use the
232
330
  // shared transport without extending JsonRpcClient themselves.
233
- request(t, s) {
234
- return super.request(t, s);
331
+ request(e, s) {
332
+ return super.request(e, s);
235
333
  }
236
- sendNotification(t, s) {
237
- super.sendNotification(t, s);
334
+ sendNotification(e, s) {
335
+ super.sendNotification(e, s);
238
336
  }
239
- registerNotificationHandler(t, s) {
240
- super.registerNotificationHandler(t, s);
337
+ registerNotificationHandler(e, s) {
338
+ super.registerNotificationHandler(e, s);
241
339
  }
242
340
  }
243
- const m = {
341
+ const w = {
244
342
  callTool: !0,
245
343
  sendMessageToHost: !0,
246
344
  readResource: !0,
@@ -260,7 +358,7 @@ const m = {
260
358
  // TODO
261
359
  getTheme: !0,
262
360
  resize: !0
263
- }, y = {
361
+ }, A = {
264
362
  callTool: !0,
265
363
  sendMessageToHost: !0,
266
364
  readResource: !1,
@@ -279,7 +377,7 @@ const m = {
279
377
  displayModal: !0,
280
378
  getTheme: !0,
281
379
  resize: !1
282
- }, A = {
380
+ }, I = {
283
381
  callTool: !1,
284
382
  sendMessageToHost: !0,
285
383
  readResource: !1,
@@ -298,7 +396,7 @@ const m = {
298
396
  displayModal: !1,
299
397
  getTheme: !0,
300
398
  resize: !1
301
- }, I = {
399
+ }, b = {
302
400
  callTool: !1,
303
401
  sendMessageToHost: !1,
304
402
  readResource: !1,
@@ -318,32 +416,32 @@ const m = {
318
416
  getTheme: !1,
319
417
  resize: !1
320
418
  };
321
- function R(e) {
322
- switch (e) {
323
- case i.MCPApps:
324
- return { ...m };
325
- case i.OpenAI:
326
- return { ...y };
327
- case i.SalesforceACC:
419
+ function E(t) {
420
+ switch (t) {
421
+ case o.MCPApps:
422
+ return { ...w };
423
+ case o.OpenAI:
328
424
  return { ...A };
329
- case i.Mosaic:
330
- case i.WebApp:
331
- case i.MicroFrontend:
332
- default:
425
+ case o.SalesforceACC:
333
426
  return { ...I };
427
+ case o.Mosaic:
428
+ case o.WebApp:
429
+ case o.MicroFrontend:
430
+ default:
431
+ return { ...b };
334
432
  }
335
433
  }
336
434
  const P = /* @__PURE__ */ new Set(["then", "catch", "finally"]);
337
- function H(e, t) {
338
- return new Proxy(e, {
435
+ function O(t, e) {
436
+ return new Proxy(t, {
339
437
  get(s, n, r) {
340
438
  if (typeof n == "symbol" || P.has(n)) {
341
- const o = Reflect.get(s, n, r);
342
- return typeof o == "function" ? o.bind(s) : o;
439
+ const i = Reflect.get(s, n, r);
440
+ return typeof i == "function" ? i.bind(s) : i;
343
441
  }
344
442
  throw new TypeError(
345
- `\`${t}()\` returns a Promise — did you forget to await it?
346
- Use \`const sdk = await ${t}();\` before accessing SDK methods.`
443
+ `\`${e}()\` returns a Promise — did you forget to await it?
444
+ Use \`const sdk = await ${e}();\` before accessing SDK methods.`
347
445
  );
348
446
  }
349
447
  });
@@ -351,15 +449,16 @@ Use \`const sdk = await ${t}();\` before accessing SDK methods.`
351
449
  export {
352
450
  M as JsonRpcClient,
353
451
  a as McpAppsSession,
354
- i as Surface,
452
+ H as MessageChannelTransport,
453
+ o as Surface,
355
454
  T as WindowPostMessageTransport,
356
455
  S as getSurface,
357
- R as getSurfaceCapabilities,
358
- l as isJsonRpcBase,
359
- u as isJsonRpcErrorResponse,
456
+ E as getSurfaceCapabilities,
457
+ u as isJsonRpcBase,
458
+ l as isJsonRpcErrorResponse,
360
459
  g as isJsonRpcNotification,
361
- b as isJsonRpcRequest,
362
- h as isJsonRpcResponse,
363
- p as isJsonRpcSuccessResponse,
364
- H as wrapSDKPromise
460
+ R as isJsonRpcRequest,
461
+ p as isJsonRpcResponse,
462
+ h as isJsonRpcSuccessResponse,
463
+ O as wrapSDKPromise
365
464
  };
@@ -0,0 +1,79 @@
1
+ import { Transport } from '../jsonrpc-client';
2
+ /**
3
+ * Subscriber callback invoked for each unwrapped payload delivered on the
4
+ * port. Receivers get the `MessageEvent.data` directly — they do not need
5
+ * to reach into a `MessageEvent` wrapper.
6
+ */
7
+ export type MessageChannelTransportListener = (msg: unknown) => void;
8
+ /**
9
+ * MFE-side `Transport` backed by a `MessagePort`.
10
+ *
11
+ * During the MFE handshake, the iframe receives a transferred `MessagePort`
12
+ * (`event.ports[0]`) in the single bootstrap envelope posted by the host.
13
+ * That port is the `port1` half of the host's `MessageChannel`. Wrapping it
14
+ * in this class produces the same `Transport` shape that `JsonRpcClient`
15
+ * already consumes, so callers can swap in MessagePort-backed traffic
16
+ * without changing any of the JSON-RPC request/response/notification
17
+ * semantics.
18
+ *
19
+ * The implementation mirrors the host-side `MessageChannelTransport` that
20
+ * ships from `packages/core/src/MessageChannelTransport.ts` in the
21
+ * `ui-embedding` repo. Both sides MUST honour the same contract so one
22
+ * `JsonRpcClient` can drive either end.
23
+ *
24
+ * Contract (symmetric with the host-side transport, and with the
25
+ * `Transport` interface defined next to `WindowPostMessageTransport`):
26
+ *
27
+ * - `post(msg)` never throws on transient failure. A closed / neutered /
28
+ * disposed port silently drops the message. This matches the
29
+ * optional-chaining behaviour of `WindowPostMessageTransport.post`.
30
+ * - `onMessage(cb)` delivers the **unwrapped** payload (`MessageEvent.data`),
31
+ * not the raw `MessageEvent`. Returns an unsubscribe function.
32
+ * - The port is started (`port.start()`) lazily on the first `onMessage`
33
+ * subscription. Messages queued via `post` before that first subscribe
34
+ * are buffered in-process and flushed FIFO when the port starts.
35
+ * - `dispose()` removes listeners, closes the port, clears the outbound
36
+ * buffer, and puts the transport into a terminal state where further
37
+ * `post` calls silently no-op and further `onMessage` calls return a
38
+ * no-op unsubscribe.
39
+ *
40
+ * Usage from the container bootstrap:
41
+ * ```ts
42
+ * const transport = new MessageChannelTransport(event.ports[0]);
43
+ * // Hand the transport to the session layer; subscription drives start().
44
+ * ```
45
+ */
46
+ export declare class MessageChannelTransport implements Transport {
47
+ #private;
48
+ constructor(port: MessagePort);
49
+ /**
50
+ * Post a message to the peer.
51
+ *
52
+ * Never throws on transient failure — a closed / neutered / disposed
53
+ * port silently drops the message. If the transport has not yet
54
+ * started (no `onMessage` subscriber), the message is buffered and
55
+ * flushed on first subscription.
56
+ */
57
+ post(message: unknown): void;
58
+ /**
59
+ * Subscribe to inbound messages from the peer. The callback receives
60
+ * the **unwrapped** payload (`MessageEvent.data`) — callers never see
61
+ * the `MessageEvent` wrapper.
62
+ *
63
+ * Starts the underlying port on first subscription and flushes any
64
+ * messages queued via `post` before the port was started.
65
+ *
66
+ * Returns an unsubscribe function. Calling it is idempotent.
67
+ */
68
+ onMessage(callback: MessageChannelTransportListener): () => void;
69
+ /**
70
+ * Tear down the transport:
71
+ * - remove the internal `message` listener
72
+ * - call `port.close()`
73
+ * - clear subscriber set and outbound buffer
74
+ * - subsequent `post` calls silently no-op
75
+ * - subsequent `onMessage` calls return a no-op unsubscribe
76
+ */
77
+ dispose(): void;
78
+ }
79
+ //# sourceMappingURL=message-channel-transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-channel-transport.d.ts","sourceRoot":"","sources":["../../src/mfe-protocol/message-channel-transport.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;;;GAIG;AACH,MAAM,MAAM,+BAA+B,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;AAUrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,qBAAa,uBAAwB,YAAW,SAAS;;gBAQ5C,IAAI,EAAE,WAAW;IAI7B;;;;;;;OAOG;IACH,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAqB5B;;;;;;;;;OASG;IACH,SAAS,CAAC,QAAQ,EAAE,+BAA+B,GAAG,MAAM,IAAI;IAoBhE;;;;;;;OAOG;IACH,OAAO,IAAI,IAAI;CAyDf"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/sdk-core",
3
- "version": "1.131.3",
3
+ "version": "1.133.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",