@salesforce/platform-sdk 9.14.0 → 9.16.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/TelemetryUploader-DKkdppe9.js +135 -0
- package/dist/analytics/index.js +6 -0
- package/dist/analytics-496rdIN5.js +163 -0
- package/dist/chat/index.js +227 -0
- package/dist/core/index.js +107 -0
- package/dist/data/index.js +628 -0
- package/dist/index.js +34 -1766
- package/dist/lightning/index.js +27 -0
- package/dist/mcpapps-session-BOT5CvWa.js +241 -0
- package/dist/sdk-promise-7SpSqah5.js +39 -0
- package/dist/telemetry/index.js +7 -0
- package/dist/transport-D8xgRy7y.js +95 -0
- package/dist/view/index.js +140 -0
- package/package.json +64 -4
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { w as a, g as c, S as e } from "../sdk-promise-7SpSqah5.js";
|
|
2
|
+
function s(r) {
|
|
3
|
+
return a(
|
|
4
|
+
(async () => {
|
|
5
|
+
switch (c(r?.surface)) {
|
|
6
|
+
case e.OpenAI:
|
|
7
|
+
return {};
|
|
8
|
+
case e.WebApp:
|
|
9
|
+
return {};
|
|
10
|
+
case e.MicroFrontend:
|
|
11
|
+
return {};
|
|
12
|
+
case e.SalesforceACC:
|
|
13
|
+
return {};
|
|
14
|
+
case e.MCPApps:
|
|
15
|
+
return {};
|
|
16
|
+
case e.Mosaic:
|
|
17
|
+
return {};
|
|
18
|
+
default:
|
|
19
|
+
return {};
|
|
20
|
+
}
|
|
21
|
+
})(),
|
|
22
|
+
"createLightningSDK"
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
s as createLightningSDK
|
|
27
|
+
};
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
function d(n) {
|
|
2
|
+
return typeof n == "object" && n !== null && !Array.isArray(n);
|
|
3
|
+
}
|
|
4
|
+
function u(n) {
|
|
5
|
+
return typeof n.id == "number" && Number.isInteger(n.id) && n.id >= 0;
|
|
6
|
+
}
|
|
7
|
+
function c(n) {
|
|
8
|
+
return d(n) && n.jsonrpc === "2.0";
|
|
9
|
+
}
|
|
10
|
+
function f(n) {
|
|
11
|
+
if (!c(n)) return !1;
|
|
12
|
+
const t = n;
|
|
13
|
+
return !("id" in t) && typeof t.method == "string";
|
|
14
|
+
}
|
|
15
|
+
function l(n) {
|
|
16
|
+
if (!c(n)) return !1;
|
|
17
|
+
const t = n;
|
|
18
|
+
return u(t) && "result" in t && !("error" in t) && !("method" in t);
|
|
19
|
+
}
|
|
20
|
+
function h(n) {
|
|
21
|
+
if (!c(n)) return !1;
|
|
22
|
+
const t = n;
|
|
23
|
+
if (!u(t) || "result" in t || "method" in t) return !1;
|
|
24
|
+
const e = t.error;
|
|
25
|
+
return d(e) && typeof e.code == "number";
|
|
26
|
+
}
|
|
27
|
+
function g(n) {
|
|
28
|
+
return l(n) || h(n);
|
|
29
|
+
}
|
|
30
|
+
class m {
|
|
31
|
+
nextRequestId = 1;
|
|
32
|
+
pending = /* @__PURE__ */ new Map();
|
|
33
|
+
notificationHandlers = /* @__PURE__ */ new Map();
|
|
34
|
+
transport;
|
|
35
|
+
/**
|
|
36
|
+
* Construct a JSON-RPC client bound to the given transport.
|
|
37
|
+
*
|
|
38
|
+
* @param transport - the transport to use.
|
|
39
|
+
*/
|
|
40
|
+
constructor(t) {
|
|
41
|
+
this.transport = t, this.transport.onMessage(this.onMessage);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Register a handler for a specific JSON-RPC notification method.
|
|
45
|
+
*
|
|
46
|
+
* Subclasses can register handlers to process specific notification
|
|
47
|
+
* types. When a notification with the registered method is received,
|
|
48
|
+
* the handler will be invoked with the notification params.
|
|
49
|
+
*
|
|
50
|
+
* @param method - The notification method to handle (e.g.
|
|
51
|
+
* "ui/notifications/host-context-changed")
|
|
52
|
+
* @param handler - Callback function to process the notification params
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* this.registerNotificationHandler("ui/notifications/host-context-changed", (params) => {
|
|
56
|
+
* this.handleHostContextChanged(params);
|
|
57
|
+
* });
|
|
58
|
+
*/
|
|
59
|
+
registerNotificationHandler(t, e) {
|
|
60
|
+
this.notificationHandlers.has(t) || this.notificationHandlers.set(t, /* @__PURE__ */ new Set()), this.notificationHandlers.get(t).add(e);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Handle inbound JSON-RPC messages from the transport.
|
|
64
|
+
*
|
|
65
|
+
* Processes both responses (for requests) and notifications.
|
|
66
|
+
* Non-JSON-RPC payloads are silently ignored so that a shared transport
|
|
67
|
+
* can be used for multiple protocols without cross-talk.
|
|
68
|
+
*/
|
|
69
|
+
onMessage = (t) => {
|
|
70
|
+
if (g(t)) {
|
|
71
|
+
const e = this.pending.get(t.id);
|
|
72
|
+
if (!e)
|
|
73
|
+
return;
|
|
74
|
+
this.pending.delete(t.id), h(t) ? e.reject(new Error(t.error.message || "Request failed")) : e.resolve(t.result);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (f(t)) {
|
|
78
|
+
const e = this.notificationHandlers.get(t.method);
|
|
79
|
+
e && e.forEach((i) => i(t.params));
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Send a JSON-RPC request to the peer.
|
|
84
|
+
*
|
|
85
|
+
* @param method - The JSON-RPC method name
|
|
86
|
+
* @param params - The method parameters
|
|
87
|
+
* @returns Promise that resolves with the result or rejects with error
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* const result = await this.request("ui/message", {
|
|
91
|
+
* role: "user",
|
|
92
|
+
* content: { type: "text", text: "Hello" }
|
|
93
|
+
* });
|
|
94
|
+
*/
|
|
95
|
+
request(t, e) {
|
|
96
|
+
const i = this.nextRequestId++, o = {
|
|
97
|
+
jsonrpc: "2.0",
|
|
98
|
+
id: i,
|
|
99
|
+
method: t,
|
|
100
|
+
params: e
|
|
101
|
+
};
|
|
102
|
+
return new Promise((a, s) => {
|
|
103
|
+
this.pending.set(i, {
|
|
104
|
+
resolve: a,
|
|
105
|
+
reject: s
|
|
106
|
+
}), this.transport.post(o);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Send a JSON-RPC notification to the peer.
|
|
111
|
+
*
|
|
112
|
+
* Notifications are one-way messages that do not expect a response.
|
|
113
|
+
* Use notifications for:
|
|
114
|
+
* - Informing the host of state changes
|
|
115
|
+
* - Fire-and-forget operations
|
|
116
|
+
* - Events that don't require confirmation
|
|
117
|
+
*
|
|
118
|
+
* Use request() instead when you need:
|
|
119
|
+
* - A response from the host
|
|
120
|
+
* - Confirmation of success/failure
|
|
121
|
+
* - Return values from the operation
|
|
122
|
+
*
|
|
123
|
+
* @param method - The JSON-RPC method name
|
|
124
|
+
* @param params - Optional method parameters
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* this.sendNotification("ui/notifications/size-changed", {
|
|
128
|
+
* width: 800,
|
|
129
|
+
* height: 600
|
|
130
|
+
* });
|
|
131
|
+
*/
|
|
132
|
+
sendNotification(t, e) {
|
|
133
|
+
const i = {
|
|
134
|
+
jsonrpc: "2.0",
|
|
135
|
+
method: t,
|
|
136
|
+
params: e
|
|
137
|
+
};
|
|
138
|
+
this.transport.post(i);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
class p {
|
|
142
|
+
targetOrigin;
|
|
143
|
+
/**
|
|
144
|
+
* @param targetOrigin - origin passed as the second argument to
|
|
145
|
+
* `window.parent.postMessage`.
|
|
146
|
+
*/
|
|
147
|
+
constructor(t) {
|
|
148
|
+
this.targetOrigin = t;
|
|
149
|
+
}
|
|
150
|
+
post(t) {
|
|
151
|
+
window.parent?.postMessage(t, this.targetOrigin);
|
|
152
|
+
}
|
|
153
|
+
onMessage(t) {
|
|
154
|
+
const e = (i) => {
|
|
155
|
+
t(i.data);
|
|
156
|
+
};
|
|
157
|
+
return window.addEventListener("message", e), () => window.removeEventListener("message", e);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
const w = 500, x = "2026-01-26";
|
|
161
|
+
class r extends m {
|
|
162
|
+
static initPromise = null;
|
|
163
|
+
hostCtx = {};
|
|
164
|
+
_handshakeSucceeded = !1;
|
|
165
|
+
/**
|
|
166
|
+
* Get or create the shared session singleton.
|
|
167
|
+
*
|
|
168
|
+
* The first call performs the SEP-1865 handshake. Concurrent and subsequent
|
|
169
|
+
* calls reuse the same session and handshake result.
|
|
170
|
+
*
|
|
171
|
+
* @param options - Optional configuration. `targetOrigin` defaults to `"*"`
|
|
172
|
+
* when omitted; pin to the concrete MCP host origin whenever known.
|
|
173
|
+
*/
|
|
174
|
+
static async getInstance(t) {
|
|
175
|
+
if (!r.initPromise) {
|
|
176
|
+
const e = t?.targetOrigin ?? "*";
|
|
177
|
+
r.initPromise = (async () => {
|
|
178
|
+
const i = new r(new p(e));
|
|
179
|
+
return await i.handshake(t), i;
|
|
180
|
+
})();
|
|
181
|
+
}
|
|
182
|
+
return r.initPromise;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Reset the singleton (for testing only).
|
|
186
|
+
* @internal
|
|
187
|
+
*/
|
|
188
|
+
static resetInstance() {
|
|
189
|
+
r.initPromise = null;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Perform the ui/initialize → hostContext → ui/notifications/initialized handshake.
|
|
193
|
+
*
|
|
194
|
+
* On success, stores the host context and sends the initialized notification.
|
|
195
|
+
* On timeout or error, falls back to an empty host context so the app can
|
|
196
|
+
* still render (graceful degradation for non-SEP-1865 hosts).
|
|
197
|
+
*/
|
|
198
|
+
async handshake(t) {
|
|
199
|
+
const e = t?.handshakeTimeoutMs ?? w, i = t?.appInfo ?? { name: "mcp-app", version: "1.0.0" };
|
|
200
|
+
try {
|
|
201
|
+
const o = /* @__PURE__ */ Symbol("timeout"), a = await Promise.race([
|
|
202
|
+
this.request("ui/initialize", {
|
|
203
|
+
protocolVersion: x,
|
|
204
|
+
appInfo: i,
|
|
205
|
+
appCapabilities: {}
|
|
206
|
+
}),
|
|
207
|
+
new Promise((s) => setTimeout(() => s(o), e))
|
|
208
|
+
]);
|
|
209
|
+
a !== o && (this.hostCtx = a.hostContext ?? {}, this._handshakeSucceeded = !0, this.registerNotificationHandler("ui/notifications/host-context-changed", (s) => {
|
|
210
|
+
this.hostCtx = {
|
|
211
|
+
...this.hostCtx,
|
|
212
|
+
...s
|
|
213
|
+
};
|
|
214
|
+
}), this.sendNotification("ui/notifications/initialized"));
|
|
215
|
+
} catch {
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/** Returns the current host context (handshake + notification updates). */
|
|
219
|
+
getHostContext() {
|
|
220
|
+
return this.hostCtx;
|
|
221
|
+
}
|
|
222
|
+
/** Whether the ui/initialize handshake completed successfully (not timed out). */
|
|
223
|
+
get handshakeSucceeded() {
|
|
224
|
+
return this._handshakeSucceeded;
|
|
225
|
+
}
|
|
226
|
+
// ── Public wrappers ──────────────────────────────────────────────────
|
|
227
|
+
// Widen access from protected to public so SDK classes can use the
|
|
228
|
+
// shared transport without extending JsonRpcClient themselves.
|
|
229
|
+
request(t, e) {
|
|
230
|
+
return super.request(t, e);
|
|
231
|
+
}
|
|
232
|
+
sendNotification(t, e) {
|
|
233
|
+
super.sendNotification(t, e);
|
|
234
|
+
}
|
|
235
|
+
registerNotificationHandler(t, e) {
|
|
236
|
+
super.registerNotificationHandler(t, e);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
export {
|
|
240
|
+
r as M
|
|
241
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var s = /* @__PURE__ */ ((e) => (e.WebApp = "WebApp", e.MicroFrontend = "Micro-Frontend", e.OpenAI = "OpenAI", e.SalesforceACC = "Salesforce-ACC", e.MCPApps = "MCP-Apps", e.Mosaic = "Mosaic", e))(s || {});
|
|
2
|
+
const c = a();
|
|
3
|
+
function a() {
|
|
4
|
+
if (typeof window > "u")
|
|
5
|
+
return "Mosaic";
|
|
6
|
+
if (window.openai)
|
|
7
|
+
return "OpenAI";
|
|
8
|
+
try {
|
|
9
|
+
if (window.self !== window.top)
|
|
10
|
+
return "Micro-Frontend";
|
|
11
|
+
} catch {
|
|
12
|
+
return "Micro-Frontend";
|
|
13
|
+
}
|
|
14
|
+
const e = window;
|
|
15
|
+
return e.$A || e.Aura ? "Salesforce-ACC" : "WebApp";
|
|
16
|
+
}
|
|
17
|
+
function f(e) {
|
|
18
|
+
return e ?? c;
|
|
19
|
+
}
|
|
20
|
+
const w = /* @__PURE__ */ new Set(["then", "catch", "finally"]);
|
|
21
|
+
function d(e, o) {
|
|
22
|
+
return new Proxy(e, {
|
|
23
|
+
get(r, n, i) {
|
|
24
|
+
if (typeof n == "symbol" || w.has(n)) {
|
|
25
|
+
const t = Reflect.get(r, n, i);
|
|
26
|
+
return typeof t == "function" ? t.bind(r) : t;
|
|
27
|
+
}
|
|
28
|
+
throw new TypeError(
|
|
29
|
+
`\`${o}()\` returns a Promise — did you forget to await it?
|
|
30
|
+
Use \`const sdk = await ${o}();\` before accessing SDK methods.`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
s as S,
|
|
37
|
+
f as g,
|
|
38
|
+
d as w
|
|
39
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
function l(s) {
|
|
2
|
+
let e = "";
|
|
3
|
+
for (let t = 0; t < s.length; t += 8192)
|
|
4
|
+
e += String.fromCharCode.apply(null, Array.from(s.subarray(t, t + 8192)));
|
|
5
|
+
return btoa(e);
|
|
6
|
+
}
|
|
7
|
+
class d {
|
|
8
|
+
entries = [];
|
|
9
|
+
totalBytes = 0;
|
|
10
|
+
maxBufferSize;
|
|
11
|
+
onError;
|
|
12
|
+
constructor(e) {
|
|
13
|
+
this.maxBufferSize = e.maxBufferSize, this.onError = e.onError;
|
|
14
|
+
}
|
|
15
|
+
get size() {
|
|
16
|
+
return this.totalBytes;
|
|
17
|
+
}
|
|
18
|
+
get isEmpty() {
|
|
19
|
+
return this.entries.length === 0;
|
|
20
|
+
}
|
|
21
|
+
enqueue(e, i) {
|
|
22
|
+
const t = l(e), r = {
|
|
23
|
+
data: t,
|
|
24
|
+
traceId: i?.traceId,
|
|
25
|
+
instanceId: i?.instanceId,
|
|
26
|
+
componentRef: i?.componentRef,
|
|
27
|
+
timestamp: Date.now()
|
|
28
|
+
}, n = t.length;
|
|
29
|
+
this.entries.push(r), this.totalBytes += n, this.totalBytes > this.maxBufferSize && this.evict();
|
|
30
|
+
}
|
|
31
|
+
drain() {
|
|
32
|
+
const e = this.entries;
|
|
33
|
+
return this.entries = [], this.totalBytes = 0, e;
|
|
34
|
+
}
|
|
35
|
+
evict() {
|
|
36
|
+
let e = 0;
|
|
37
|
+
for (; this.totalBytes > this.maxBufferSize && this.entries.length > 1; ) {
|
|
38
|
+
const i = this.entries.shift();
|
|
39
|
+
this.totalBytes -= i.data.length, e++;
|
|
40
|
+
}
|
|
41
|
+
e > 0 && this.onError?.({ reason: "buffer_overflow", droppedCount: e });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const u = "telemetry/upload";
|
|
45
|
+
class f {
|
|
46
|
+
buffer;
|
|
47
|
+
sdk;
|
|
48
|
+
onError;
|
|
49
|
+
timerId = null;
|
|
50
|
+
disposed = !1;
|
|
51
|
+
handleVisibilityChange = () => {
|
|
52
|
+
document.visibilityState === "hidden" && this.flush();
|
|
53
|
+
};
|
|
54
|
+
handlePageHide = () => {
|
|
55
|
+
this.flush();
|
|
56
|
+
};
|
|
57
|
+
constructor(e, i, t) {
|
|
58
|
+
this.buffer = e, this.sdk = i, this.onError = t.onError, this.timerId = setInterval(() => this.flush(), t.flushInterval), document.addEventListener("visibilitychange", this.handleVisibilityChange), window.addEventListener("pagehide", this.handlePageHide);
|
|
59
|
+
}
|
|
60
|
+
flush() {
|
|
61
|
+
if (this.buffer.isEmpty || !this.sdk.callTool)
|
|
62
|
+
return;
|
|
63
|
+
const i = this.buffer.drain().map(c);
|
|
64
|
+
this.sdk.callTool({ toolName: u, params: { inputs: [{ envelopes: i }] } }).catch((t) => {
|
|
65
|
+
this.onError?.({ reason: "tool_call_failed", error: t });
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
dispose() {
|
|
69
|
+
this.disposed || (this.disposed = !0, this.timerId !== null && (clearInterval(this.timerId), this.timerId = null), document.removeEventListener("visibilitychange", this.handleVisibilityChange), window.removeEventListener("pagehide", this.handlePageHide), this.flush());
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function c(s) {
|
|
73
|
+
const e = { base64Env: s.data };
|
|
74
|
+
return s.traceId !== void 0 && (e.traceId = s.traceId), e;
|
|
75
|
+
}
|
|
76
|
+
const m = 65536, p = 3e4;
|
|
77
|
+
function y(s) {
|
|
78
|
+
const {
|
|
79
|
+
sdk: e,
|
|
80
|
+
maxBufferSize: i = m,
|
|
81
|
+
flushInterval: t = p,
|
|
82
|
+
onError: r
|
|
83
|
+
} = s, n = new d({ maxBufferSize: i, onError: r }), o = new f(n, e, { flushInterval: t, onError: r });
|
|
84
|
+
return {
|
|
85
|
+
enqueue(a, h) {
|
|
86
|
+
n.enqueue(a, h);
|
|
87
|
+
},
|
|
88
|
+
dispose() {
|
|
89
|
+
o.dispose();
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
export {
|
|
94
|
+
y as c
|
|
95
|
+
};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { w as p, g as d, S as a } from "../sdk-promise-7SpSqah5.js";
|
|
2
|
+
import { M as m } from "../mcpapps-session-BOT5CvWa.js";
|
|
3
|
+
function f(s) {
|
|
4
|
+
switch (s) {
|
|
5
|
+
case "info":
|
|
6
|
+
return "ℹ️";
|
|
7
|
+
case "success":
|
|
8
|
+
return "✅";
|
|
9
|
+
case "warning":
|
|
10
|
+
return "⚠️";
|
|
11
|
+
case "error":
|
|
12
|
+
return "❌";
|
|
13
|
+
default:
|
|
14
|
+
return "ℹ️";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function c(s, e) {
|
|
18
|
+
return `${f(e)} ${s}`;
|
|
19
|
+
}
|
|
20
|
+
function l(s, e) {
|
|
21
|
+
const t = s.trim();
|
|
22
|
+
if (t === "")
|
|
23
|
+
return { success: !0, value: void 0 };
|
|
24
|
+
const r = t.match(/^(\d+(?:\.\d+)?)(px)?$/);
|
|
25
|
+
if (!r || !r[1])
|
|
26
|
+
return {
|
|
27
|
+
success: !1,
|
|
28
|
+
error: `Invalid ${e}: "${s}". Only pixel values are supported (e.g., "800px" or "800").`
|
|
29
|
+
};
|
|
30
|
+
const n = parseFloat(r[1]);
|
|
31
|
+
return n < 0 || !isFinite(n) ? {
|
|
32
|
+
success: !1,
|
|
33
|
+
error: `Invalid ${e}: "${s}". Value must be a positive number.`
|
|
34
|
+
} : { success: !0, value: n };
|
|
35
|
+
}
|
|
36
|
+
class w {
|
|
37
|
+
constructor(e) {
|
|
38
|
+
this.session = e;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Send a formatted message to the host via ui/message
|
|
42
|
+
* @param message - The message text
|
|
43
|
+
* @param level - The message severity level (defaults to "info")
|
|
44
|
+
*/
|
|
45
|
+
async sendMessage(e, t = "info") {
|
|
46
|
+
const r = c(e, t);
|
|
47
|
+
await this.session.request("ui/message", {
|
|
48
|
+
role: "user",
|
|
49
|
+
content: [
|
|
50
|
+
{
|
|
51
|
+
type: "text",
|
|
52
|
+
text: r
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
async displayAlert(e) {
|
|
58
|
+
await this.sendMessage(e.message, e.level);
|
|
59
|
+
}
|
|
60
|
+
async displayToast(e) {
|
|
61
|
+
await this.sendMessage(e.message, e.level);
|
|
62
|
+
}
|
|
63
|
+
async displayModal(e) {
|
|
64
|
+
return Promise.resolve();
|
|
65
|
+
}
|
|
66
|
+
getTheme() {
|
|
67
|
+
const e = this.session.getHostContext().theme;
|
|
68
|
+
return e ? { mode: e } : null;
|
|
69
|
+
}
|
|
70
|
+
async resize(e, t) {
|
|
71
|
+
const r = l(e, "width");
|
|
72
|
+
if (!r.success)
|
|
73
|
+
return Promise.reject(new Error(r.error));
|
|
74
|
+
const n = l(t, "height");
|
|
75
|
+
if (!n.success)
|
|
76
|
+
return Promise.reject(new Error(n.error));
|
|
77
|
+
const o = {};
|
|
78
|
+
return r.value !== void 0 && (o.width = r.value), n.value !== void 0 && (o.height = n.value), this.session.sendNotification("ui/notifications/size-changed", o), Promise.resolve();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
class h {
|
|
82
|
+
async displayAlert(e) {
|
|
83
|
+
const t = e.level || "info", r = c(e.message, t);
|
|
84
|
+
await window.openai.sendFollowUpMessage({ prompt: r });
|
|
85
|
+
}
|
|
86
|
+
async displayToast(e) {
|
|
87
|
+
const t = e.level || "info", r = c(e.message, t);
|
|
88
|
+
await window.openai.sendFollowUpMessage({ prompt: r });
|
|
89
|
+
}
|
|
90
|
+
async displayModal(e) {
|
|
91
|
+
await window.openai.requestModal({
|
|
92
|
+
template: e.componentReference,
|
|
93
|
+
params: e.params
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
getTheme() {
|
|
97
|
+
const e = window.openai.theme;
|
|
98
|
+
return e ? { mode: e } : null;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
let i = null, u = null;
|
|
102
|
+
function M(s) {
|
|
103
|
+
return i || (i = g(s).then((e) => (u = e, e))), i;
|
|
104
|
+
}
|
|
105
|
+
function S() {
|
|
106
|
+
return u;
|
|
107
|
+
}
|
|
108
|
+
function A() {
|
|
109
|
+
i = null, u = null;
|
|
110
|
+
}
|
|
111
|
+
function g(s) {
|
|
112
|
+
return p(
|
|
113
|
+
(async () => {
|
|
114
|
+
switch (d(s?.surface)) {
|
|
115
|
+
case a.OpenAI:
|
|
116
|
+
return new h();
|
|
117
|
+
case a.WebApp:
|
|
118
|
+
case a.Mosaic:
|
|
119
|
+
return {};
|
|
120
|
+
case a.SalesforceACC:
|
|
121
|
+
return {};
|
|
122
|
+
case a.MicroFrontend:
|
|
123
|
+
case a.MCPApps: {
|
|
124
|
+
const t = await m.getInstance(s?.mcpApps);
|
|
125
|
+
return t.handshakeSucceeded ? new w(t) : {};
|
|
126
|
+
}
|
|
127
|
+
default:
|
|
128
|
+
return {};
|
|
129
|
+
}
|
|
130
|
+
})(),
|
|
131
|
+
"createViewSDK"
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
export {
|
|
135
|
+
w as MCPAppsViewSDK,
|
|
136
|
+
g as createViewSDK,
|
|
137
|
+
M as getViewSDK,
|
|
138
|
+
S as getViewSDKSync,
|
|
139
|
+
A as resetViewSDK
|
|
140
|
+
};
|
package/package.json
CHANGED
|
@@ -1,19 +1,79 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/platform-sdk",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.16.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"sideEffects": false,
|
|
10
|
+
"typesVersions": {
|
|
11
|
+
"*": {
|
|
12
|
+
"core": [
|
|
13
|
+
"./dist/core/index.d.ts"
|
|
14
|
+
],
|
|
15
|
+
"chat": [
|
|
16
|
+
"./dist/chat/index.d.ts"
|
|
17
|
+
],
|
|
18
|
+
"view": [
|
|
19
|
+
"./dist/view/index.d.ts"
|
|
20
|
+
],
|
|
21
|
+
"data": [
|
|
22
|
+
"./dist/data/index.d.ts"
|
|
23
|
+
],
|
|
24
|
+
"lightning": [
|
|
25
|
+
"./dist/lightning/index.d.ts"
|
|
26
|
+
],
|
|
27
|
+
"telemetry": [
|
|
28
|
+
"./dist/telemetry/index.d.ts"
|
|
29
|
+
],
|
|
30
|
+
"analytics": [
|
|
31
|
+
"./dist/analytics/index.d.ts"
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
10
35
|
"exports": {
|
|
11
|
-
"./package.json": "./package.json",
|
|
12
36
|
".": {
|
|
13
37
|
"types": "./dist/index.d.ts",
|
|
14
38
|
"import": "./dist/index.js",
|
|
15
39
|
"default": "./dist/index.js"
|
|
16
|
-
}
|
|
40
|
+
},
|
|
41
|
+
"./core": {
|
|
42
|
+
"types": "./dist/core/index.d.ts",
|
|
43
|
+
"import": "./dist/core/index.js",
|
|
44
|
+
"default": "./dist/core/index.js"
|
|
45
|
+
},
|
|
46
|
+
"./chat": {
|
|
47
|
+
"types": "./dist/chat/index.d.ts",
|
|
48
|
+
"import": "./dist/chat/index.js",
|
|
49
|
+
"default": "./dist/chat/index.js"
|
|
50
|
+
},
|
|
51
|
+
"./view": {
|
|
52
|
+
"types": "./dist/view/index.d.ts",
|
|
53
|
+
"import": "./dist/view/index.js",
|
|
54
|
+
"default": "./dist/view/index.js"
|
|
55
|
+
},
|
|
56
|
+
"./data": {
|
|
57
|
+
"types": "./dist/data/index.d.ts",
|
|
58
|
+
"import": "./dist/data/index.js",
|
|
59
|
+
"default": "./dist/data/index.js"
|
|
60
|
+
},
|
|
61
|
+
"./lightning": {
|
|
62
|
+
"types": "./dist/lightning/index.d.ts",
|
|
63
|
+
"import": "./dist/lightning/index.js",
|
|
64
|
+
"default": "./dist/lightning/index.js"
|
|
65
|
+
},
|
|
66
|
+
"./telemetry": {
|
|
67
|
+
"types": "./dist/telemetry/index.d.ts",
|
|
68
|
+
"import": "./dist/telemetry/index.js",
|
|
69
|
+
"default": "./dist/telemetry/index.js"
|
|
70
|
+
},
|
|
71
|
+
"./analytics": {
|
|
72
|
+
"types": "./dist/analytics/index.d.ts",
|
|
73
|
+
"import": "./dist/analytics/index.js",
|
|
74
|
+
"default": "./dist/analytics/index.js"
|
|
75
|
+
},
|
|
76
|
+
"./package.json": "./package.json"
|
|
17
77
|
},
|
|
18
78
|
"files": [
|
|
19
79
|
"dist"
|
|
@@ -36,7 +96,7 @@
|
|
|
36
96
|
"@conduit-client/service-pubsub": "3.19.6",
|
|
37
97
|
"@conduit-client/service-retry": "3.19.6",
|
|
38
98
|
"@conduit-client/utils": "3.19.6",
|
|
39
|
-
"@salesforce/jsonrpc": "^9.
|
|
99
|
+
"@salesforce/jsonrpc": "^9.16.0"
|
|
40
100
|
},
|
|
41
101
|
"peerDependencies": {
|
|
42
102
|
"o11y": ">=260.0.0",
|