@salesforce/sdk-view 1.103.2
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/LICENSE.txt +82 -0
- package/README.md +41 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +119 -0
- package/dist/mcpapps.d.ts +24 -0
- package/dist/mcpapps.d.ts.map +1 -0
- package/dist/openai.d.ts +11 -0
- package/dist/openai.d.ts.map +1 -0
- package/dist/utils.d.ts +59 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +39 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
Terms of Use
|
|
2
|
+
|
|
3
|
+
Copyright 2026 Salesforce, Inc. All rights reserved.
|
|
4
|
+
|
|
5
|
+
These Terms of Use govern the download, installation, and/or use of this
|
|
6
|
+
software provided by Salesforce, Inc. ("Salesforce") (the "Software"), were
|
|
7
|
+
last updated on April 15, 2025, and constitute a legally binding
|
|
8
|
+
agreement between you and Salesforce. If you do not agree to these Terms of
|
|
9
|
+
Use, do not install or use the Software.
|
|
10
|
+
|
|
11
|
+
Salesforce grants you a worldwide, non-exclusive, no-charge, royalty-free
|
|
12
|
+
copyright license to reproduce, prepare derivative works of, publicly
|
|
13
|
+
display, publicly perform, sublicense, and distribute the Software and
|
|
14
|
+
derivative works subject to these Terms. These Terms shall be included in
|
|
15
|
+
all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
Subject to the limited rights expressly granted hereunder, Salesforce
|
|
18
|
+
reserves all rights, title, and interest in and to all intellectual
|
|
19
|
+
property subsisting in the Software. No rights are granted to you hereunder
|
|
20
|
+
other than as expressly set forth herein. Users residing in countries on
|
|
21
|
+
the United States Office of Foreign Assets Control sanction list, or which
|
|
22
|
+
are otherwise subject to a US export embargo, may not use the Software.
|
|
23
|
+
|
|
24
|
+
Implementation of the Software may require development work, for which you
|
|
25
|
+
are responsible. The Software may contain bugs, errors and
|
|
26
|
+
incompatibilities and is made available on an AS IS basis without support,
|
|
27
|
+
updates, or service level commitments.
|
|
28
|
+
|
|
29
|
+
Salesforce reserves the right at any time to modify, suspend, or
|
|
30
|
+
discontinue, the Software (or any part thereof) with or without notice. You
|
|
31
|
+
agree that Salesforce shall not be liable to you or to any third party for
|
|
32
|
+
any modification, suspension, or discontinuance.
|
|
33
|
+
|
|
34
|
+
You agree to defend Salesforce against any claim, demand, suit or
|
|
35
|
+
proceeding made or brought against Salesforce by a third party arising out
|
|
36
|
+
of or accruing from (a) your use of the Software, and (b) any application
|
|
37
|
+
you develop with the Software that infringes any copyright, trademark,
|
|
38
|
+
trade secret, trade dress, patent, or other intellectual property right of
|
|
39
|
+
any person or defames any person or violates their rights of publicity or
|
|
40
|
+
privacy (each a "Claim Against Salesforce"), and will indemnify Salesforce
|
|
41
|
+
from any damages, attorney fees, and costs finally awarded against
|
|
42
|
+
Salesforce as a result of, or for any amounts paid by Salesforce under a
|
|
43
|
+
settlement approved by you in writing of, a Claim Against Salesforce,
|
|
44
|
+
provided Salesforce (x) promptly gives you written notice of the Claim
|
|
45
|
+
Against Salesforce, (y) gives you sole control of the defense and
|
|
46
|
+
settlement of the Claim Against Salesforce (except that you may not settle
|
|
47
|
+
any Claim Against Salesforce unless it unconditionally releases Salesforce
|
|
48
|
+
of all liability), and (z) gives you all reasonable assistance, at your
|
|
49
|
+
expense.
|
|
50
|
+
|
|
51
|
+
WITHOUT LIMITING THE GENERALITY OF THE FOREGOING, THE SOFTWARE IS NOT
|
|
52
|
+
SUPPORTED AND IS PROVIDED "AS IS," WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
53
|
+
IMPLIED. IN NO EVENT SHALL SALESFORCE HAVE ANY LIABILITY FOR ANY DAMAGES,
|
|
54
|
+
INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, SPECIAL, INCIDENTAL,
|
|
55
|
+
PUNITIVE, OR CONSEQUENTIAL DAMAGES, OR DAMAGES BASED ON LOST PROFITS, DATA,
|
|
56
|
+
OR USE, IN CONNECTION WITH THE SOFTWARE, HOWEVER CAUSED AND WHETHER IN
|
|
57
|
+
CONTRACT, TORT, OR UNDER ANY OTHER THEORY OF LIABILITY, WHETHER OR NOT YOU
|
|
58
|
+
HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
59
|
+
|
|
60
|
+
These Terms of Use shall be governed exclusively by the internal laws of
|
|
61
|
+
the State of California, without regard to its conflicts of laws
|
|
62
|
+
rules. Each party hereby consents to the exclusive jurisdiction of the
|
|
63
|
+
state and federal courts located in San Francisco County, California to
|
|
64
|
+
adjudicate any dispute arising out of or relating to these Terms of Use and
|
|
65
|
+
the download, installation, and/or use of the Software. Except as expressly
|
|
66
|
+
stated herein, these Terms of Use constitute the entire agreement between
|
|
67
|
+
the parties, and supersede all prior and contemporaneous agreements,
|
|
68
|
+
proposals, or representations, written or oral, concerning their subject
|
|
69
|
+
matter. No modification, amendment, or waiver of any provision of these
|
|
70
|
+
Terms of Use shall be effective unless it is by an update to these Terms of
|
|
71
|
+
Use that Salesforce makes available, or is in writing and signed by the
|
|
72
|
+
party against whom the modification, amendment, or waiver is to be
|
|
73
|
+
asserted.
|
|
74
|
+
|
|
75
|
+
Data Privacy: Salesforce may collect, process, and store device,
|
|
76
|
+
system, and other information related to your use of the Software. This
|
|
77
|
+
information includes, but is not limited to, IP address, user metrics, and
|
|
78
|
+
other data ("Usage Data"). Salesforce may use Usage Data for analytics,
|
|
79
|
+
product development, and marketing purposes. You acknowledge that files
|
|
80
|
+
generated in conjunction with the Software may contain sensitive or
|
|
81
|
+
confidential data, and you are solely responsible for anonymizing and
|
|
82
|
+
protecting such data.
|
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# @salesforce/sdk-view
|
|
2
|
+
|
|
3
|
+
The View SDK provides a unified interface for visual interactions and user feedback across different Salesforce application surfaces. It handles notifications, alerts, and modal dialogs, automatically adapting to the hosting environment.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
The View SDK manages interactions that affect the visual shell or user feedback, independent of business data. It abstracts away the complexity of different hosting environments, allowing applications to deliver consistent user experiences whether running in a web application, embedded iframe, or conversational interface.
|
|
8
|
+
|
|
9
|
+
## Key Capabilities
|
|
10
|
+
|
|
11
|
+
- **Notifications**: Display alerts, toasts, and confirmations appropriate to the hosting environment
|
|
12
|
+
- **Modals**: Request the host to overlay modal dialogs, even within iframe constraints
|
|
13
|
+
- **Surface Adaptation**: Automatically detects and adapts to the runtime environment
|
|
14
|
+
|
|
15
|
+
## Supported Surfaces
|
|
16
|
+
|
|
17
|
+
The View SDK supports the following application surfaces:
|
|
18
|
+
|
|
19
|
+
- **Web Applications**: Standard Salesforce web applications with native browser capabilities
|
|
20
|
+
- **Micro Frontends**: Embedded iframe applications that communicate through the host bridge
|
|
21
|
+
- **OpenAI ChatGPT Apps**: Conversational interfaces integrated with ChatGPT
|
|
22
|
+
|
|
23
|
+
## Architecture
|
|
24
|
+
|
|
25
|
+
The View SDK is part of the Salesforce Platform SDK ecosystem and works alongside other domain-specific SDKs:
|
|
26
|
+
|
|
27
|
+
- **@salesforce/sdk-core**: Provides runtime detection and initialization
|
|
28
|
+
- **@salesforce/sdk-data**: Unified data access layer
|
|
29
|
+
- **@salesforce/sdk-chat**: Conversational flow participation
|
|
30
|
+
|
|
31
|
+
## Status
|
|
32
|
+
|
|
33
|
+
**Status:** Experimental (Private Package)
|
|
34
|
+
|
|
35
|
+
This package is currently marked as private and intended for internal use within the Salesforce Web Applications monorepo.
|
|
36
|
+
|
|
37
|
+
## License
|
|
38
|
+
|
|
39
|
+
Copyright (c) 2026, Salesforce, Inc.
|
|
40
|
+
All rights reserved.
|
|
41
|
+
For full license text, see the LICENSE.txt file.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SDKOptions, ViewSDK, McpAppsSessionOptions } from '@salesforce/sdk-core';
|
|
2
|
+
/**
|
|
3
|
+
* Options for creating a ViewSDK instance.
|
|
4
|
+
*/
|
|
5
|
+
export interface ViewSDKOptions extends SDKOptions {
|
|
6
|
+
/** MCP Apps session options (app identity, handshake timeout) */
|
|
7
|
+
mcpApps?: McpAppsSessionOptions;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Create and initialize a ViewSDK instance based on the detected surface
|
|
11
|
+
*
|
|
12
|
+
* For MCP Apps surfaces, this obtains the shared {@link McpAppsSession} singleton
|
|
13
|
+
* (performing the SEP-1865 handshake on the first call across all SDK factories).
|
|
14
|
+
*
|
|
15
|
+
* @param options - Optional configuration including surface override
|
|
16
|
+
* @returns Promise resolving to an initialized ViewSDK instance
|
|
17
|
+
*/
|
|
18
|
+
export declare function createViewSDK(options?: ViewSDKOptions): Promise<ViewSDK>;
|
|
19
|
+
export { MCPAppsViewSDK } from './mcpapps';
|
|
20
|
+
export type { AlertOptions, ModalOptions, SDKOptions, Theme, ThemeMode, ToastOptions, ViewSDK, } from '@salesforce/sdk-core';
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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;AAE3C,YAAY,EACX,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,KAAK,EACL,SAAS,EACT,YAAY,EACZ,OAAO,GACP,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { getSurface as l, Surface as a, McpAppsSession as d } from "@salesforce/sdk-core";
|
|
2
|
+
function p(r) {
|
|
3
|
+
switch (r) {
|
|
4
|
+
case "info":
|
|
5
|
+
return "ℹ️";
|
|
6
|
+
case "success":
|
|
7
|
+
return "✅";
|
|
8
|
+
case "warning":
|
|
9
|
+
return "⚠️";
|
|
10
|
+
case "error":
|
|
11
|
+
return "❌";
|
|
12
|
+
default:
|
|
13
|
+
return "ℹ️";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function o(r, e) {
|
|
17
|
+
return `${p(e)} ${r}`;
|
|
18
|
+
}
|
|
19
|
+
function c(r, e) {
|
|
20
|
+
const s = r.trim();
|
|
21
|
+
if (s === "")
|
|
22
|
+
return { success: !0, value: void 0 };
|
|
23
|
+
const t = s.match(/^(\d+(?:\.\d+)?)(px)?$/);
|
|
24
|
+
if (!t || !t[1])
|
|
25
|
+
return {
|
|
26
|
+
success: !1,
|
|
27
|
+
error: `Invalid ${e}: "${r}". Only pixel values are supported (e.g., "800px" or "800").`
|
|
28
|
+
};
|
|
29
|
+
const n = parseFloat(t[1]);
|
|
30
|
+
return n < 0 || !isFinite(n) ? {
|
|
31
|
+
success: !1,
|
|
32
|
+
error: `Invalid ${e}: "${r}". Value must be a positive number.`
|
|
33
|
+
} : { success: !0, value: n };
|
|
34
|
+
}
|
|
35
|
+
class m {
|
|
36
|
+
constructor(e) {
|
|
37
|
+
this.session = e;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Send a formatted message to the host via ui/message
|
|
41
|
+
* @param message - The message text
|
|
42
|
+
* @param level - The message severity level (defaults to "info")
|
|
43
|
+
*/
|
|
44
|
+
async sendMessage(e, s = "info") {
|
|
45
|
+
const t = o(e, s);
|
|
46
|
+
await this.session.request("ui/message", {
|
|
47
|
+
role: "user",
|
|
48
|
+
content: [
|
|
49
|
+
{
|
|
50
|
+
type: "text",
|
|
51
|
+
text: t
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
async displayAlert(e) {
|
|
57
|
+
await this.sendMessage(e.message, e.level);
|
|
58
|
+
}
|
|
59
|
+
async displayToast(e) {
|
|
60
|
+
await this.sendMessage(e.message, e.level);
|
|
61
|
+
}
|
|
62
|
+
async displayModal(e) {
|
|
63
|
+
return Promise.resolve();
|
|
64
|
+
}
|
|
65
|
+
getTheme() {
|
|
66
|
+
const e = this.session.getHostContext().theme;
|
|
67
|
+
return e ? { mode: e } : null;
|
|
68
|
+
}
|
|
69
|
+
async resize(e, s) {
|
|
70
|
+
const t = c(e, "width");
|
|
71
|
+
if (!t.success)
|
|
72
|
+
return Promise.reject(new Error(t.error));
|
|
73
|
+
const n = c(s, "height");
|
|
74
|
+
if (!n.success)
|
|
75
|
+
return Promise.reject(new Error(n.error));
|
|
76
|
+
const i = {};
|
|
77
|
+
return t.value !== void 0 && (i.width = t.value), n.value !== void 0 && (i.height = n.value), this.session.sendNotification("ui/notifications/size-changed", i), Promise.resolve();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
class u {
|
|
81
|
+
async displayAlert(e) {
|
|
82
|
+
const s = e.level || "info", t = o(e.message, s);
|
|
83
|
+
await window.openai.sendFollowUpMessage({ prompt: t });
|
|
84
|
+
}
|
|
85
|
+
async displayToast(e) {
|
|
86
|
+
const s = e.level || "info", t = o(e.message, s);
|
|
87
|
+
await window.openai.sendFollowUpMessage({ prompt: t });
|
|
88
|
+
}
|
|
89
|
+
async displayModal(e) {
|
|
90
|
+
await window.openai.requestModal({
|
|
91
|
+
template: e.componentReference,
|
|
92
|
+
params: e.params
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
getTheme() {
|
|
96
|
+
return window.openai.theme;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
async function w(r) {
|
|
100
|
+
switch (l(r?.surface)) {
|
|
101
|
+
case a.OpenAI:
|
|
102
|
+
return new u();
|
|
103
|
+
case a.WebApp:
|
|
104
|
+
case a.MicroFrontend:
|
|
105
|
+
return {};
|
|
106
|
+
case a.SalesforceACC:
|
|
107
|
+
return {};
|
|
108
|
+
case a.MCPApps: {
|
|
109
|
+
const s = await d.getInstance(r?.mcpApps);
|
|
110
|
+
return s.handshakeSucceeded ? new m(s) : window.openai ? new u() : {};
|
|
111
|
+
}
|
|
112
|
+
default:
|
|
113
|
+
return {};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
export {
|
|
117
|
+
m as MCPAppsViewSDK,
|
|
118
|
+
w as createViewSDK
|
|
119
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ViewSDK, AlertOptions, ToastOptions, ModalOptions, Theme, McpAppsSession } from '@salesforce/sdk-core';
|
|
2
|
+
/**
|
|
3
|
+
* ViewSDK implementation for MCP Apps surface.
|
|
4
|
+
*
|
|
5
|
+
* Uses a shared {@link McpAppsSession} for JSON-RPC 2.0 transport instead of
|
|
6
|
+
* owning its own postMessage listener, avoiding duplicate listeners and ID
|
|
7
|
+
* counter collisions when used alongside MCPAppsChatSDK.
|
|
8
|
+
*/
|
|
9
|
+
export declare class MCPAppsViewSDK implements ViewSDK {
|
|
10
|
+
private session;
|
|
11
|
+
constructor(session: McpAppsSession);
|
|
12
|
+
/**
|
|
13
|
+
* Send a formatted message to the host via ui/message
|
|
14
|
+
* @param message - The message text
|
|
15
|
+
* @param level - The message severity level (defaults to "info")
|
|
16
|
+
*/
|
|
17
|
+
private sendMessage;
|
|
18
|
+
displayAlert(options: AlertOptions): Promise<void>;
|
|
19
|
+
displayToast(options: ToastOptions): Promise<void>;
|
|
20
|
+
displayModal(_options: ModalOptions): Promise<void>;
|
|
21
|
+
getTheme(): Theme | null;
|
|
22
|
+
resize(width: string, height: string): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=mcpapps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpapps.d.ts","sourceRoot":"","sources":["../src/mcpapps.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EACX,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,KAAK,EAEL,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D;;;;;;GAMG;AACH,qBAAa,cAAe,YAAW,OAAO;IACjC,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,cAAc;IAE3C;;;;OAIG;YACW,WAAW;IAcnB,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlD,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlD,YAAY,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAKzD,QAAQ,IAAI,KAAK,GAAG,IAAI;IAKlB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CA2B1D"}
|
package/dist/openai.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ViewSDK, AlertOptions, ToastOptions, ModalOptions, Theme } from '@salesforce/sdk-core';
|
|
2
|
+
/**
|
|
3
|
+
* ViewSDK implementation for OpenAI surface
|
|
4
|
+
*/
|
|
5
|
+
export declare class OpenAIViewSDK implements ViewSDK {
|
|
6
|
+
displayAlert(options: AlertOptions): Promise<void>;
|
|
7
|
+
displayToast(options: ToastOptions): Promise<void>;
|
|
8
|
+
displayModal(options: ModalOptions): Promise<void>;
|
|
9
|
+
getTheme(): Theme | null;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=openai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../src/openai.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EACX,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,KAAK,EACL,MAAM,sBAAsB,CAAC;AAG9B;;GAEG;AACH,qBAAa,aAAc,YAAW,OAAO;IACtC,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAOlD,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAOlD,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAOxD,QAAQ,IAAI,KAAK,GAAG,IAAI;CAGxB"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { MessageLevel } from '@salesforce/sdk-core';
|
|
2
|
+
/**
|
|
3
|
+
* Get the icon emoji for a given message level
|
|
4
|
+
*
|
|
5
|
+
* Maps message severity levels to their corresponding emoji icons:
|
|
6
|
+
* - info: ℹ️
|
|
7
|
+
* - success: ✅
|
|
8
|
+
* - warning: ⚠️
|
|
9
|
+
* - error: ❌
|
|
10
|
+
*
|
|
11
|
+
* @param level - The message severity level
|
|
12
|
+
* @returns The emoji icon for the level
|
|
13
|
+
*/
|
|
14
|
+
export declare function getIconForLevel(level: MessageLevel): string;
|
|
15
|
+
/**
|
|
16
|
+
* Format a message with an icon based on the severity level
|
|
17
|
+
*
|
|
18
|
+
* Prepends the appropriate emoji icon to the message text.
|
|
19
|
+
*
|
|
20
|
+
* @param message - The message text
|
|
21
|
+
* @param level - The message severity level
|
|
22
|
+
* @returns The formatted message with icon prefix (e.g., "ℹ️ Your message")
|
|
23
|
+
*/
|
|
24
|
+
export declare function formatMessageWithLevel(message: string, level: MessageLevel): string;
|
|
25
|
+
/**
|
|
26
|
+
* Result type for dimension parsing
|
|
27
|
+
*/
|
|
28
|
+
export type ParseDimensionResult = {
|
|
29
|
+
success: true;
|
|
30
|
+
value: number | undefined;
|
|
31
|
+
} | {
|
|
32
|
+
success: false;
|
|
33
|
+
error: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Parse a dimension string to a numeric pixel value
|
|
37
|
+
*
|
|
38
|
+
* Supports formats:
|
|
39
|
+
* - "800px" - pixel value with unit
|
|
40
|
+
* - "800" - unitless value (treated as pixels)
|
|
41
|
+
* - "" - empty string returns undefined
|
|
42
|
+
*
|
|
43
|
+
* Rejects with error message:
|
|
44
|
+
* - Invalid formats (e.g., "800rem", "50%", "auto")
|
|
45
|
+
* - Negative values
|
|
46
|
+
* - Non-numeric values
|
|
47
|
+
*
|
|
48
|
+
* @param value - The dimension string to parse
|
|
49
|
+
* @param dimensionName - Name of the dimension for error messages ("width" or "height")
|
|
50
|
+
* @returns Result object with success flag and either value or error message
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* parseDimension("800px", "width") // Returns { success: true, value: 800 }
|
|
54
|
+
* parseDimension("600", "height") // Returns { success: true, value: 600 }
|
|
55
|
+
* parseDimension("", "width") // Returns { success: true, value: undefined }
|
|
56
|
+
* parseDimension("50%", "width") // Returns { success: false, error: "Invalid width..." }
|
|
57
|
+
*/
|
|
58
|
+
export declare function parseDimension(value: string, dimensionName: string): ParseDimensionResult;
|
|
59
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAa3D;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,MAAM,CAGnF;AAED;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAC7B;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAC5C;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,oBAAoB,CAiCzF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@salesforce/sdk-view",
|
|
3
|
+
"version": "1.103.2",
|
|
4
|
+
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
"./package.json": "./package.json",
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "vite build",
|
|
22
|
+
"clean": "rm -rf dist",
|
|
23
|
+
"dev": "vite build --watch",
|
|
24
|
+
"test": "vitest run",
|
|
25
|
+
"test:watch": "vitest",
|
|
26
|
+
"test:coverage": "vitest run --coverage"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@salesforce/sdk-core": "^1.103.2"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"vite": "^7.3.1",
|
|
33
|
+
"vite-plugin-dts": "^4.5.4",
|
|
34
|
+
"vitest": "^4.0.6"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
}
|
|
39
|
+
}
|