@salesforce/sdk-view 1.114.0 → 1.115.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 +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +51 -38
- package/dist/singleton.d.ts +32 -0
- package/dist/singleton.d.ts.map +1 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -17,5 +17,6 @@ export interface ViewSDKOptions extends SDKOptions {
|
|
|
17
17
|
*/
|
|
18
18
|
export declare function createViewSDK(options?: ViewSDKOptions): Promise<ViewSDK>;
|
|
19
19
|
export { MCPAppsViewSDK } from './mcpapps';
|
|
20
|
+
export { getViewSDK, getViewSDKSync, resetViewSDK } from './singleton';
|
|
20
21
|
export type { AlertOptions, ModalOptions, SDKOptions, Theme, ThemeMode, ToastOptions, ViewSDK, } from '@salesforce/sdk-core';
|
|
21
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAIvF;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,UAAU;IACjD,iEAAiE;IACjE,OAAO,CAAC,EAAE,qBAAqB,CAAC;CAChC;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAyB9E;AAED,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAIvF;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,UAAU;IACjD,iEAAiE;IACjE,OAAO,CAAC,EAAE,qBAAqB,CAAC;CAChC;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAyB9E;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,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getSurface as
|
|
2
|
-
function
|
|
3
|
-
switch (
|
|
1
|
+
import { getSurface as p, Surface as a, McpAppsSession as f } from "@salesforce/sdk-core";
|
|
2
|
+
function m(s) {
|
|
3
|
+
switch (s) {
|
|
4
4
|
case "info":
|
|
5
5
|
return "ℹ️";
|
|
6
6
|
case "success":
|
|
@@ -13,26 +13,26 @@ function p(r) {
|
|
|
13
13
|
return "ℹ️";
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
return `${
|
|
16
|
+
function c(s, e) {
|
|
17
|
+
return `${m(e)} ${s}`;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
19
|
+
function l(s, e) {
|
|
20
|
+
const t = s.trim();
|
|
21
|
+
if (t === "")
|
|
22
22
|
return { success: !0, value: void 0 };
|
|
23
|
-
const
|
|
24
|
-
if (!
|
|
23
|
+
const n = t.match(/^(\d+(?:\.\d+)?)(px)?$/);
|
|
24
|
+
if (!n || !n[1])
|
|
25
25
|
return {
|
|
26
26
|
success: !1,
|
|
27
|
-
error: `Invalid ${e}: "${
|
|
27
|
+
error: `Invalid ${e}: "${s}". Only pixel values are supported (e.g., "800px" or "800").`
|
|
28
28
|
};
|
|
29
|
-
const
|
|
30
|
-
return
|
|
29
|
+
const r = parseFloat(n[1]);
|
|
30
|
+
return r < 0 || !isFinite(r) ? {
|
|
31
31
|
success: !1,
|
|
32
|
-
error: `Invalid ${e}: "${
|
|
33
|
-
} : { success: !0, value:
|
|
32
|
+
error: `Invalid ${e}: "${s}". Value must be a positive number.`
|
|
33
|
+
} : { success: !0, value: r };
|
|
34
34
|
}
|
|
35
|
-
class
|
|
35
|
+
class w {
|
|
36
36
|
constructor(e) {
|
|
37
37
|
this.session = e;
|
|
38
38
|
}
|
|
@@ -41,14 +41,14 @@ class m {
|
|
|
41
41
|
* @param message - The message text
|
|
42
42
|
* @param level - The message severity level (defaults to "info")
|
|
43
43
|
*/
|
|
44
|
-
async sendMessage(e,
|
|
45
|
-
const
|
|
44
|
+
async sendMessage(e, t = "info") {
|
|
45
|
+
const n = c(e, t);
|
|
46
46
|
await this.session.request("ui/message", {
|
|
47
47
|
role: "user",
|
|
48
48
|
content: [
|
|
49
49
|
{
|
|
50
50
|
type: "text",
|
|
51
|
-
text:
|
|
51
|
+
text: n
|
|
52
52
|
}
|
|
53
53
|
]
|
|
54
54
|
});
|
|
@@ -66,25 +66,25 @@ class m {
|
|
|
66
66
|
const e = this.session.getHostContext().theme;
|
|
67
67
|
return e ? { mode: e } : null;
|
|
68
68
|
}
|
|
69
|
-
async resize(e,
|
|
70
|
-
const
|
|
71
|
-
if (!t.success)
|
|
72
|
-
return Promise.reject(new Error(t.error));
|
|
73
|
-
const n = c(s, "height");
|
|
69
|
+
async resize(e, t) {
|
|
70
|
+
const n = l(e, "width");
|
|
74
71
|
if (!n.success)
|
|
75
72
|
return Promise.reject(new Error(n.error));
|
|
76
|
-
const
|
|
77
|
-
|
|
73
|
+
const r = l(t, "height");
|
|
74
|
+
if (!r.success)
|
|
75
|
+
return Promise.reject(new Error(r.error));
|
|
76
|
+
const o = {};
|
|
77
|
+
return n.value !== void 0 && (o.width = n.value), r.value !== void 0 && (o.height = r.value), this.session.sendNotification("ui/notifications/size-changed", o), Promise.resolve();
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
class
|
|
80
|
+
class d {
|
|
81
81
|
async displayAlert(e) {
|
|
82
|
-
const
|
|
83
|
-
await window.openai.sendFollowUpMessage({ prompt:
|
|
82
|
+
const t = e.level || "info", n = c(e.message, t);
|
|
83
|
+
await window.openai.sendFollowUpMessage({ prompt: n });
|
|
84
84
|
}
|
|
85
85
|
async displayToast(e) {
|
|
86
|
-
const
|
|
87
|
-
await window.openai.sendFollowUpMessage({ prompt:
|
|
86
|
+
const t = e.level || "info", n = c(e.message, t);
|
|
87
|
+
await window.openai.sendFollowUpMessage({ prompt: n });
|
|
88
88
|
}
|
|
89
89
|
async displayModal(e) {
|
|
90
90
|
await window.openai.requestModal({
|
|
@@ -97,24 +97,37 @@ class u {
|
|
|
97
97
|
return e ? { mode: e } : null;
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
let i = null, u = null;
|
|
101
|
+
function v(s) {
|
|
102
|
+
return i || (i = h(s).then((e) => (u = e, e))), i;
|
|
103
|
+
}
|
|
104
|
+
function y() {
|
|
105
|
+
return u;
|
|
106
|
+
}
|
|
107
|
+
function M() {
|
|
108
|
+
i = null, u = null;
|
|
109
|
+
}
|
|
110
|
+
async function h(s) {
|
|
111
|
+
switch (p(s?.surface)) {
|
|
102
112
|
case a.OpenAI:
|
|
103
|
-
return new
|
|
113
|
+
return new d();
|
|
104
114
|
case a.WebApp:
|
|
105
115
|
case a.MicroFrontend:
|
|
106
116
|
return {};
|
|
107
117
|
case a.SalesforceACC:
|
|
108
118
|
return {};
|
|
109
119
|
case a.MCPApps: {
|
|
110
|
-
const
|
|
111
|
-
return
|
|
120
|
+
const t = await f.getInstance(s?.mcpApps);
|
|
121
|
+
return t.handshakeSucceeded ? new w(t) : window.openai ? new d() : {};
|
|
112
122
|
}
|
|
113
123
|
default:
|
|
114
124
|
return {};
|
|
115
125
|
}
|
|
116
126
|
}
|
|
117
127
|
export {
|
|
118
|
-
|
|
119
|
-
|
|
128
|
+
w as MCPAppsViewSDK,
|
|
129
|
+
h as createViewSDK,
|
|
130
|
+
v as getViewSDK,
|
|
131
|
+
y as getViewSDKSync,
|
|
132
|
+
M as resetViewSDK
|
|
120
133
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ViewSDK } from '@salesforce/sdk-core';
|
|
2
|
+
import { ViewSDKOptions } from './index';
|
|
3
|
+
/**
|
|
4
|
+
* Get or create a singleton ViewSDK instance.
|
|
5
|
+
*
|
|
6
|
+
* The first caller may provide options (e.g. surface-specific configuration).
|
|
7
|
+
* Subsequent callers receive the same cached Promise regardless of arguments.
|
|
8
|
+
*
|
|
9
|
+
* The Promise itself is cached (not the resolved value) so concurrent callers
|
|
10
|
+
* do not race to create multiple instances.
|
|
11
|
+
*
|
|
12
|
+
* @param options - Optional configuration (only used on first call)
|
|
13
|
+
* @returns Promise resolving to the shared ViewSDK instance
|
|
14
|
+
*/
|
|
15
|
+
export declare function getViewSDK(options?: ViewSDKOptions): Promise<ViewSDK>;
|
|
16
|
+
/**
|
|
17
|
+
* Synchronously get the singleton ViewSDK instance.
|
|
18
|
+
*
|
|
19
|
+
* Returns the resolved instance if {@link getViewSDK} has already been
|
|
20
|
+
* called and completed, or `null` if not yet initialized. Use this in
|
|
21
|
+
* contexts where async is not available (e.g., imperative mosaic components).
|
|
22
|
+
*
|
|
23
|
+
* @returns The singleton ViewSDK instance, or null if not yet ready
|
|
24
|
+
*/
|
|
25
|
+
export declare function getViewSDKSync(): ViewSDK | null;
|
|
26
|
+
/**
|
|
27
|
+
* Reset the singleton ViewSDK cache.
|
|
28
|
+
*
|
|
29
|
+
* Useful for testing and session reset scenarios.
|
|
30
|
+
*/
|
|
31
|
+
export declare function resetViewSDK(): void;
|
|
32
|
+
//# sourceMappingURL=singleton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"singleton.d.ts","sourceRoot":"","sources":["../src/singleton.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAK9C;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAQrE;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,IAAI,OAAO,GAAG,IAAI,CAE/C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,IAAI,CAGnC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/sdk-view",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.115.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"test:coverage": "vitest run --coverage"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@salesforce/sdk-core": "^1.
|
|
29
|
+
"@salesforce/sdk-core": "^1.115.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"vite": "^7.3.1",
|