@salesforce/sdk-core 1.22.0 → 1.30.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/chat.d.ts +135 -0
- package/dist/chat.d.ts.map +1 -0
- package/dist/data.d.ts +107 -0
- package/dist/data.d.ts.map +1 -0
- package/dist/data.js +6 -0
- package/dist/index.d.ts +6 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -33
- package/dist/lightning.d.ts +42 -0
- package/dist/lightning.d.ts.map +1 -0
- package/dist/lightning.js +6 -0
- package/dist/{types.d.ts → platforms.d.ts} +8 -11
- package/dist/platforms.d.ts.map +1 -0
- package/dist/platforms.js +6 -0
- package/dist/surface.d.ts +17 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +43 -0
- package/dist/view.d.ts +291 -0
- package/dist/view.d.ts.map +1 -0
- package/dist/view.js +6 -0
- package/package.json +2 -2
- package/dist/types.d.ts.map +0 -1
- /package/dist/{types.js → chat.js} +0 -0
package/dist/chat.d.ts
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Message payload for chat stream
|
|
8
|
+
*/
|
|
9
|
+
export interface ChatMessage {
|
|
10
|
+
content: string;
|
|
11
|
+
metadata?: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Tool execution payload
|
|
15
|
+
*/
|
|
16
|
+
export interface ToolCall {
|
|
17
|
+
toolName: string;
|
|
18
|
+
params?: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Resource read request
|
|
22
|
+
*/
|
|
23
|
+
export interface ResourceRequest {
|
|
24
|
+
uri: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Tool input/output state
|
|
28
|
+
*/
|
|
29
|
+
export interface ToolState<T = unknown> {
|
|
30
|
+
data: T;
|
|
31
|
+
timestamp?: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Display modes
|
|
35
|
+
* - inline: Normal embedded view in chat
|
|
36
|
+
* - fullscreen: Expanded full-screen view
|
|
37
|
+
* - pip: Picture-in-Picture (floating panel)
|
|
38
|
+
*/
|
|
39
|
+
export type DisplayMode = "inline" | "fullscreen" | "pip";
|
|
40
|
+
/**
|
|
41
|
+
* Chat SDK API with optional methods based on surface capabilities
|
|
42
|
+
*/
|
|
43
|
+
export interface ChatSDK {
|
|
44
|
+
/**
|
|
45
|
+
* Send a message to the host
|
|
46
|
+
*
|
|
47
|
+
* @param message - The message to send
|
|
48
|
+
*/
|
|
49
|
+
sendMessageToHost?: (message: ChatMessage) => Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Execute a tool on the MCP Server
|
|
52
|
+
*
|
|
53
|
+
* @param toolCall - The tool to call with parameters
|
|
54
|
+
*/
|
|
55
|
+
callTool?: <T>(toolCall: ToolCall) => Promise<T>;
|
|
56
|
+
/**
|
|
57
|
+
* Access the current tool input data
|
|
58
|
+
*
|
|
59
|
+
* @returns The tool input data or null if not available
|
|
60
|
+
*/
|
|
61
|
+
accessToolInput?: <T>() => ToolState<T> | null;
|
|
62
|
+
/**
|
|
63
|
+
* Access the current tool output data
|
|
64
|
+
*
|
|
65
|
+
* @returns The tool output data or null if not available
|
|
66
|
+
*/
|
|
67
|
+
accessToolOutput?: <T>() => ToolState<T> | null;
|
|
68
|
+
/**
|
|
69
|
+
* Access metadata about the current tool
|
|
70
|
+
*
|
|
71
|
+
* @returns Tool metadata including schema, description, etc.
|
|
72
|
+
*/
|
|
73
|
+
accessToolMetadata?: <T>() => T | null;
|
|
74
|
+
/**
|
|
75
|
+
* Get the current widget state
|
|
76
|
+
*
|
|
77
|
+
* @returns The widget state or null if not available
|
|
78
|
+
*/
|
|
79
|
+
getWidgetState?: <T>() => T | null;
|
|
80
|
+
/**
|
|
81
|
+
* Set the widget state
|
|
82
|
+
*
|
|
83
|
+
* @param state - The widget state to persist
|
|
84
|
+
*/
|
|
85
|
+
setWidgetState?: <T>(state: T) => void;
|
|
86
|
+
/**
|
|
87
|
+
* Read resource content by URI
|
|
88
|
+
*
|
|
89
|
+
* @param request - The resource request with URI
|
|
90
|
+
*/
|
|
91
|
+
readResource?: <T>(request: ResourceRequest) => Promise<T>;
|
|
92
|
+
/**
|
|
93
|
+
* Register a callback for when tool execution is canceled
|
|
94
|
+
*
|
|
95
|
+
* @param callback - Function to call when tool is canceled
|
|
96
|
+
*/
|
|
97
|
+
onToolCanceled?: (callback: () => void) => void;
|
|
98
|
+
/**
|
|
99
|
+
* Get available follow-up actions
|
|
100
|
+
*
|
|
101
|
+
* @returns Array of available actions
|
|
102
|
+
*/
|
|
103
|
+
followUpActions?: <T>() => T[];
|
|
104
|
+
/**
|
|
105
|
+
* Set the display mode for the widget
|
|
106
|
+
*
|
|
107
|
+
* @param mode - The desired display mode
|
|
108
|
+
* @returns Promise resolving to the applied display mode
|
|
109
|
+
*/
|
|
110
|
+
setDisplayMode?: (mode: DisplayMode) => Promise<{
|
|
111
|
+
mode: DisplayMode;
|
|
112
|
+
}>;
|
|
113
|
+
/**
|
|
114
|
+
* Subscribe to data changes from the host
|
|
115
|
+
*
|
|
116
|
+
* This method provides a platform-agnostic way to listen for changes to
|
|
117
|
+
* tool input, output, metadata, and other SDK data. It's designed to work
|
|
118
|
+
* with React's useSyncExternalStore and other reactive patterns.
|
|
119
|
+
*
|
|
120
|
+
* @param callback - Function to call when data changes
|
|
121
|
+
* @returns Cleanup function to unsubscribe
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* const unsubscribe = sdk.subscribe?.(() => {
|
|
126
|
+
* console.log('SDK data changed');
|
|
127
|
+
* });
|
|
128
|
+
*
|
|
129
|
+
* // Later, cleanup
|
|
130
|
+
* unsubscribe?.();
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
subscribe?: (callback: () => void) => () => void;
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=chat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../src/chat.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,GAAG,EAAE,MAAM,CAAC;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC,GAAG,OAAO;IACrC,IAAI,EAAE,CAAC,CAAC;IACR,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,YAAY,GAAG,KAAK,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,OAAO;IACvB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5D;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;IAEjD;;;;OAIG;IACH,eAAe,CAAC,EAAE,CAAC,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAE/C;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,CAAC,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAEhD;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;IAEvC;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;IAEnC;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAEvC;;;;OAIG;IACH,YAAY,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;IAE3D;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;IAEhD;;;;OAIG;IACH,eAAe,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IAE/B;;;;;OAKG;IACH,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,WAAW,CAAA;KAAE,CAAC,CAAC;IAEvE;;;;;;;;;;;;;;;;;;;OAmBG;IACH,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;CACjD"}
|
package/dist/data.d.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
export interface GraphQLResponse<T> {
|
|
7
|
+
data: T;
|
|
8
|
+
errors?: {
|
|
9
|
+
message: string;
|
|
10
|
+
locations?: {
|
|
11
|
+
line: number;
|
|
12
|
+
column: number;
|
|
13
|
+
}[];
|
|
14
|
+
path?: string[];
|
|
15
|
+
}[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Custom label request options
|
|
19
|
+
*/
|
|
20
|
+
export interface LabelRequest {
|
|
21
|
+
/**
|
|
22
|
+
* Label name (e.g., 'c.MyCustomLabel')
|
|
23
|
+
*/
|
|
24
|
+
labelName: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Resource URL request options
|
|
28
|
+
*/
|
|
29
|
+
export interface ResourceUrlRequest {
|
|
30
|
+
/**
|
|
31
|
+
* Resource path (e.g., 'images/logo.png')
|
|
32
|
+
*/
|
|
33
|
+
resourcePath: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* User information from Salesforce
|
|
37
|
+
*/
|
|
38
|
+
export interface UserInfo {
|
|
39
|
+
userId: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Schema descriptor request options
|
|
43
|
+
*/
|
|
44
|
+
export interface SchemaRequest {
|
|
45
|
+
/**
|
|
46
|
+
* Object API name (e.g., 'Account', 'Contact')
|
|
47
|
+
*/
|
|
48
|
+
objectApiName: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Schema descriptor response
|
|
52
|
+
*/
|
|
53
|
+
export interface SchemaDescriptor {
|
|
54
|
+
apiName: string;
|
|
55
|
+
label: string;
|
|
56
|
+
fields: {
|
|
57
|
+
apiName: string;
|
|
58
|
+
label: string;
|
|
59
|
+
dataType: string;
|
|
60
|
+
required: boolean;
|
|
61
|
+
}[];
|
|
62
|
+
}
|
|
63
|
+
export interface DataSDK {
|
|
64
|
+
/**
|
|
65
|
+
* Run a GraphQL query
|
|
66
|
+
*
|
|
67
|
+
* @param query
|
|
68
|
+
* @param variables
|
|
69
|
+
*/
|
|
70
|
+
graphql?: <T, V = Record<string, unknown>>(query: string, variables?: V) => Promise<GraphQLResponse<T>>;
|
|
71
|
+
/**
|
|
72
|
+
* Make a request using the Fetch API.
|
|
73
|
+
*
|
|
74
|
+
* @param input - The URL or Request object
|
|
75
|
+
* @param init - Optional RequestInit configuration
|
|
76
|
+
* @returns Promise resolving to Response
|
|
77
|
+
*/
|
|
78
|
+
fetch?: typeof fetch;
|
|
79
|
+
/**
|
|
80
|
+
* Request a custom label value
|
|
81
|
+
*
|
|
82
|
+
* @param request - Label request configuration
|
|
83
|
+
* @returns Promise resolving to the label value
|
|
84
|
+
*/
|
|
85
|
+
getLabel?: (request: LabelRequest) => Promise<string>;
|
|
86
|
+
/**
|
|
87
|
+
* Request a static resource URL
|
|
88
|
+
*
|
|
89
|
+
* @param request - Resource URL request
|
|
90
|
+
* @returns Promise resolving to the resource URL
|
|
91
|
+
*/
|
|
92
|
+
getResourceUrl?: (request: ResourceUrlRequest) => Promise<string>;
|
|
93
|
+
/**
|
|
94
|
+
* Get current user information
|
|
95
|
+
*
|
|
96
|
+
* @returns Promise resolving to user info
|
|
97
|
+
*/
|
|
98
|
+
getUserInfo?: () => Promise<UserInfo>;
|
|
99
|
+
/**
|
|
100
|
+
* Get schema descriptor for a Salesforce object
|
|
101
|
+
*
|
|
102
|
+
* @param request - Schema request configuration
|
|
103
|
+
* @returns Promise resolving to the schema descriptor
|
|
104
|
+
*/
|
|
105
|
+
getSchema?: (request: SchemaRequest) => Promise<SchemaDescriptor>;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../src/data.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,eAAe,CAAC,CAAC;IACjC,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,CAAC,EAAE;QACR,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QAC/C,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;KAChB,EAAE,CAAC;CACJ;AAED;;GAEG;AAC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gB,CAAC,CAAC;CAClE"}
|
package/dist/data.js
ADDED
package/dist/index.d.ts
CHANGED
|
@@ -3,15 +3,10 @@
|
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
* For full license text, see the LICENSE.txt file
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
OpenAI = "OpenAI",
|
|
13
|
-
SalesforceACC = "Salesforce-ACC"
|
|
14
|
-
}
|
|
15
|
-
export declare function getSurface(): Surface;
|
|
16
|
-
export type { AlertOptions, ChatMessage, ChatSDK, DataSDK, GraphQLResponse, MessageLevel, ModalOptions, OpenAISDK, ResourceRequest, SalesforceACCSDK, Theme, ThemeMode, ToastOptions, ToolCall, ToolState, ViewSDK, } from "./types.js";
|
|
6
|
+
export { Surface, getSurface } from "./surface.js";
|
|
7
|
+
export type { ChatMessage, ChatSDK, DisplayMode, ResourceRequest, ToolCall, ToolState, } from "./chat.js";
|
|
8
|
+
export type { AlertOptions, MessageLevel, ModalOptions, ToastOptions, Theme, ThemeMode, ViewSDK, } from "./view.js";
|
|
9
|
+
export type { DataSDK, GraphQLResponse, LabelRequest, ResourceUrlRequest, SchemaDescriptor, SchemaRequest, UserInfo, } from "./data.js";
|
|
10
|
+
export type { LightningSDK, LMSMessage, LMSSubscription, MessageChannel } from "./lightning.js";
|
|
11
|
+
export type { OpenAISDK, SalesforceACCSDK } from "./platforms.js";
|
|
17
12
|
//# 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":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAGnD,YAAY,EACX,WAAW,EACX,OAAO,EACP,WAAW,EACX,eAAe,EACf,QAAQ,EACR,SAAS,GACT,MAAM,WAAW,CAAC;AAGnB,YAAY,EACX,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,KAAK,EACL,SAAS,EACT,OAAO,GACP,MAAM,WAAW,CAAC;AAGnB,YAAY,EACX,OAAO,EACP,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,QAAQ,GACR,MAAM,WAAW,CAAC;AAGnB,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhG,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,36 +3,5 @@
|
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
* For full license text, see the LICENSE.txt file
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*/
|
|
9
|
-
export var Surface;
|
|
10
|
-
(function (Surface) {
|
|
11
|
-
Surface["Webapp"] = "Webapp";
|
|
12
|
-
Surface["MicroFrontend"] = "Micro-Frontend";
|
|
13
|
-
Surface["OpenAI"] = "OpenAI";
|
|
14
|
-
Surface["SalesforceACC"] = "Salesforce-ACC";
|
|
15
|
-
})(Surface || (Surface = {}));
|
|
16
|
-
// for ChatGPT, can we assume window.openai will already be in place upon import?
|
|
17
|
-
const surface = detectSurface();
|
|
18
|
-
/**
|
|
19
|
-
* Determines the surface
|
|
20
|
-
*/
|
|
21
|
-
function detectSurface() {
|
|
22
|
-
if (window.openai) {
|
|
23
|
-
return Surface.OpenAI;
|
|
24
|
-
}
|
|
25
|
-
else if (window.salesforceACC) {
|
|
26
|
-
// TODO: Update detection logic once actual identifier is known
|
|
27
|
-
return Surface.SalesforceACC;
|
|
28
|
-
}
|
|
29
|
-
else if (window.self !== window.top) {
|
|
30
|
-
return Surface.MicroFrontend;
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
return Surface.Webapp;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
export function getSurface() {
|
|
37
|
-
return surface;
|
|
38
|
-
}
|
|
6
|
+
// Surface detection
|
|
7
|
+
export { Surface, getSurface } from "./surface.js";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Lightning Message Service message payload
|
|
8
|
+
*/
|
|
9
|
+
export type LMSMessage = Record<string, unknown>;
|
|
10
|
+
/**
|
|
11
|
+
* Lightning Message Service subscription
|
|
12
|
+
*/
|
|
13
|
+
export interface LMSSubscription {
|
|
14
|
+
unsubscribe: () => void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Lightning Message Service channel configuration
|
|
18
|
+
*/
|
|
19
|
+
export interface MessageChannel {
|
|
20
|
+
channelName: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Lightning SDK interface for Lightning Web Component runtime integration
|
|
24
|
+
*/
|
|
25
|
+
export interface LightningSDK {
|
|
26
|
+
/**
|
|
27
|
+
* Publish a message to a Lightning Message Service channel
|
|
28
|
+
*
|
|
29
|
+
* @param channel - Message channel configuration
|
|
30
|
+
* @param message - Message payload to publish
|
|
31
|
+
*/
|
|
32
|
+
publishLmsMessage?: <M extends LMSMessage>(channel: MessageChannel, message: M) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Subscribe to a Lightning Message Service channel
|
|
35
|
+
*
|
|
36
|
+
* @param channel - Message channel configuration
|
|
37
|
+
* @param callback - Callback function to handle received messages
|
|
38
|
+
* @returns Subscription object with unsubscribe method
|
|
39
|
+
*/
|
|
40
|
+
subscribeToLmsChannel?: <M extends LMSMessage>(channel: MessageChannel, callback: (message: M) => void) => LMSSubscription;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=lightning.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lightning.d.ts","sourceRoot":"","sources":["../src/lightning.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,WAAW,EAAE,MAAM,IAAI,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,WAAW,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,CAAC,CAAC,SAAS,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC,KAAK,IAAI,CAAC;IAExF;;;;;;OAMG;IACH,qBAAqB,CAAC,EAAE,CAAC,CAAC,SAAS,UAAU,EAC5C,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,KAC1B,eAAe,CAAC;CACrB"}
|
|
@@ -7,12 +7,19 @@
|
|
|
7
7
|
* OpenAI SDK interface exposed on window
|
|
8
8
|
* All properties and methods are always available
|
|
9
9
|
*/
|
|
10
|
+
import type { DisplayMode } from "./chat.js";
|
|
11
|
+
import type { Theme } from "./view.js";
|
|
10
12
|
export interface OpenAISDK {
|
|
11
13
|
sendFollowUpMessage: (options: {
|
|
12
14
|
prompt: string;
|
|
13
15
|
}) => Promise<void>;
|
|
14
16
|
callTool: (toolName: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
15
17
|
requestModal: (options: ModalOptions) => Promise<void>;
|
|
18
|
+
requestDisplayMode: (options: {
|
|
19
|
+
mode: DisplayMode;
|
|
20
|
+
}) => Promise<{
|
|
21
|
+
mode: DisplayMode;
|
|
22
|
+
}>;
|
|
16
23
|
toolInput: Record<string, unknown>;
|
|
17
24
|
toolOutput: Record<string, unknown> | null;
|
|
18
25
|
toolResponseMetadata: Record<string, unknown>;
|
|
@@ -169,16 +176,6 @@ export interface ModalOptions {
|
|
|
169
176
|
*/
|
|
170
177
|
params?: Record<string, unknown>;
|
|
171
178
|
}
|
|
172
|
-
/**
|
|
173
|
-
* Theme mode
|
|
174
|
-
*/
|
|
175
|
-
export type ThemeMode = "light" | "dark";
|
|
176
|
-
/**
|
|
177
|
-
* Theme object
|
|
178
|
-
*/
|
|
179
|
-
export interface Theme {
|
|
180
|
-
mode: ThemeMode;
|
|
181
|
-
}
|
|
182
179
|
/**
|
|
183
180
|
* ViewSDK API
|
|
184
181
|
*/
|
|
@@ -246,4 +243,4 @@ export interface GraphQLResponse<T> {
|
|
|
246
243
|
path?: string[];
|
|
247
244
|
}[];
|
|
248
245
|
}
|
|
249
|
-
//# sourceMappingURL=
|
|
246
|
+
//# sourceMappingURL=platforms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platforms.d.ts","sourceRoot":"","sources":["../src/platforms.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACvC,MAAM,WAAW,SAAS;IACzB,mBAAmB,EAAE,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpE,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAChF,YAAY,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,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AC,CAAC;IACR,MAAM,CAAC,EAAE;QACR,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QAC/C,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;KAChB,EAAE,CAAC;CACJ"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Enumeration of possible runtime surfaces
|
|
8
|
+
*/
|
|
9
|
+
export declare enum Surface {
|
|
10
|
+
WebApp = "WebApp",
|
|
11
|
+
MicroFrontend = "Micro-Frontend",
|
|
12
|
+
OpenAI = "OpenAI",
|
|
13
|
+
SalesforceACC = "Salesforce-ACC",
|
|
14
|
+
MCPApps = "MCP-Apps"
|
|
15
|
+
}
|
|
16
|
+
export declare function getSurface(): Surface;
|
|
17
|
+
//# sourceMappingURL=surface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surface.d.ts","sourceRoot":"","sources":["../src/surface.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,oBAAY,OAAO;IAClB,MAAM,WAAW;IACjB,aAAa,mBAAmB;IAChC,MAAM,WAAW;IACjB,aAAa,mBAAmB;IAChC,OAAO,aAAa;CACpB;AAwBD,wBAAgB,UAAU,YAEzB"}
|
package/dist/surface.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Enumeration of possible runtime surfaces
|
|
8
|
+
*/
|
|
9
|
+
export var Surface;
|
|
10
|
+
(function (Surface) {
|
|
11
|
+
Surface["WebApp"] = "WebApp";
|
|
12
|
+
Surface["MicroFrontend"] = "Micro-Frontend";
|
|
13
|
+
Surface["OpenAI"] = "OpenAI";
|
|
14
|
+
Surface["SalesforceACC"] = "Salesforce-ACC";
|
|
15
|
+
Surface["MCPApps"] = "MCP-Apps";
|
|
16
|
+
})(Surface || (Surface = {}));
|
|
17
|
+
// for ChatGPT, can we assume window.openai will already be in place upon import?
|
|
18
|
+
const surface = detectSurface();
|
|
19
|
+
/**
|
|
20
|
+
* Determines the surface
|
|
21
|
+
*/
|
|
22
|
+
function detectSurface() {
|
|
23
|
+
if (window.openai) {
|
|
24
|
+
return Surface.OpenAI;
|
|
25
|
+
}
|
|
26
|
+
else if (window.salesforceACC) {
|
|
27
|
+
// TODO: Update detection logic once actual identifier is known
|
|
28
|
+
return Surface.SalesforceACC;
|
|
29
|
+
}
|
|
30
|
+
else if (window.mcpApps) {
|
|
31
|
+
// TODO: Update detection logic once actual identifier is known
|
|
32
|
+
return Surface.MCPApps;
|
|
33
|
+
}
|
|
34
|
+
else if (window.self !== window.top) {
|
|
35
|
+
return Surface.MicroFrontend;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
return Surface.WebApp;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export function getSurface() {
|
|
42
|
+
return surface;
|
|
43
|
+
}
|
package/dist/view.d.ts
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Theme mode
|
|
8
|
+
*/
|
|
9
|
+
export type ThemeMode = "light" | "dark";
|
|
10
|
+
/**
|
|
11
|
+
* Theme object
|
|
12
|
+
*/
|
|
13
|
+
export interface Theme {
|
|
14
|
+
mode: ThemeMode;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Message severity level for alerts and toasts
|
|
18
|
+
*
|
|
19
|
+
* Determines the visual styling and importance of notifications:
|
|
20
|
+
* - `info` - Informational messages (blue/neutral)
|
|
21
|
+
* - `success` - Successful operations (green)
|
|
22
|
+
* - `warning` - Warning messages requiring attention (yellow/orange)
|
|
23
|
+
* - `error` - Error messages for failed operations (red)
|
|
24
|
+
*/
|
|
25
|
+
export type MessageLevel = "info" | "success" | "warning" | "error";
|
|
26
|
+
/**
|
|
27
|
+
* Configuration options for displaying alerts
|
|
28
|
+
*
|
|
29
|
+
* Alerts are modal notifications that typically require user acknowledgment.
|
|
30
|
+
* They block interaction until dismissed and are used for important messages.
|
|
31
|
+
*/
|
|
32
|
+
export interface AlertOptions {
|
|
33
|
+
/**
|
|
34
|
+
* The message content to display in the alert
|
|
35
|
+
*/
|
|
36
|
+
message: string;
|
|
37
|
+
/**
|
|
38
|
+
* The severity level of the alert
|
|
39
|
+
*
|
|
40
|
+
* Determines the visual styling and icon. Defaults to "info" if not specified.
|
|
41
|
+
*/
|
|
42
|
+
level?: MessageLevel;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Configuration options for displaying toast notifications
|
|
46
|
+
*
|
|
47
|
+
* Toasts are non-blocking, temporary notifications that automatically dismiss
|
|
48
|
+
* after a short duration. They're ideal for status updates and confirmations.
|
|
49
|
+
*/
|
|
50
|
+
export interface ToastOptions {
|
|
51
|
+
/**
|
|
52
|
+
* The message content to display in the toast
|
|
53
|
+
*/
|
|
54
|
+
message: string;
|
|
55
|
+
/**
|
|
56
|
+
* The severity level of the toast
|
|
57
|
+
*
|
|
58
|
+
* Determines the visual styling and icon. Defaults to "info" if not specified.
|
|
59
|
+
*/
|
|
60
|
+
level?: MessageLevel;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Configuration options for displaying modal dialogs
|
|
64
|
+
*
|
|
65
|
+
* Modals allow custom HTML content to be displayed in an overlay dialog.
|
|
66
|
+
* The template is loaded from a UI resource and can receive parameters.
|
|
67
|
+
*/
|
|
68
|
+
export interface ModalOptions {
|
|
69
|
+
/**
|
|
70
|
+
* URI of the HTML template to load in the modal
|
|
71
|
+
*
|
|
72
|
+
* Format: "ui://widget/[name].html"
|
|
73
|
+
* The template file should be included in your application's UI resources.
|
|
74
|
+
*
|
|
75
|
+
* @example "ui://widget/confirmation.html"
|
|
76
|
+
* @example "ui://widget/settings.html"
|
|
77
|
+
*/
|
|
78
|
+
componentReference: string;
|
|
79
|
+
/**
|
|
80
|
+
* Parameters to pass to the modal template
|
|
81
|
+
*
|
|
82
|
+
* These parameters are accessible within the modal via the host's API.
|
|
83
|
+
* For example, in OpenAI surface: `window.openai.view.params`
|
|
84
|
+
*
|
|
85
|
+
* @example { userId: "123", mode: "edit" }
|
|
86
|
+
*/
|
|
87
|
+
params?: Record<string, unknown>;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* ViewSDK API - Provides methods for displaying UI elements and managing view state
|
|
91
|
+
*
|
|
92
|
+
* This SDK enables web applications to interact with the host's UI layer by displaying
|
|
93
|
+
* alerts, toast notifications, modal dialogs, and managing application state. All methods
|
|
94
|
+
* are optional and may not be available depending on the runtime surface.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* const viewSDK = await createViewSDK();
|
|
99
|
+
*
|
|
100
|
+
* // Display a success toast
|
|
101
|
+
* await viewSDK.displayToast?.({
|
|
102
|
+
* message: 'Operation completed successfully',
|
|
103
|
+
* level: 'success'
|
|
104
|
+
* });
|
|
105
|
+
*
|
|
106
|
+
* // Mark application as having unsaved changes
|
|
107
|
+
* await viewSDK.markDirtyState?.();
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
export interface ViewSDK {
|
|
111
|
+
/**
|
|
112
|
+
* Display an alert message in the host environment
|
|
113
|
+
*
|
|
114
|
+
* Alerts are typically modal and require user acknowledgment before dismissing.
|
|
115
|
+
* Use alerts for important messages that require immediate attention.
|
|
116
|
+
*
|
|
117
|
+
* @param options - Alert configuration options
|
|
118
|
+
* @returns Promise that resolves when the alert is displayed
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```typescript
|
|
122
|
+
* await viewSDK.displayAlert?.({
|
|
123
|
+
* message: 'Please save your work before continuing',
|
|
124
|
+
* level: 'warning'
|
|
125
|
+
* });
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
displayAlert?(options: AlertOptions): Promise<void>;
|
|
129
|
+
/**
|
|
130
|
+
* Display a toast notification in the host environment
|
|
131
|
+
*
|
|
132
|
+
* Toasts are non-blocking, temporary notifications that auto-dismiss.
|
|
133
|
+
* Use toasts for success confirmations, status updates, or informational messages
|
|
134
|
+
* that don't require user interaction.
|
|
135
|
+
*
|
|
136
|
+
* @param options - Toast configuration options
|
|
137
|
+
* @returns Promise that resolves when the toast is displayed
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```typescript
|
|
141
|
+
* await viewSDK.displayToast?.({
|
|
142
|
+
* message: 'File uploaded successfully',
|
|
143
|
+
* level: 'success'
|
|
144
|
+
* });
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
displayToast?(options: ToastOptions): Promise<void>;
|
|
148
|
+
/**
|
|
149
|
+
* Display a modal dialog with custom UI in the host environment
|
|
150
|
+
*
|
|
151
|
+
* Modals allow you to display custom HTML content in a dialog overlay.
|
|
152
|
+
* The template is loaded from a UI resource URI, and parameters can be
|
|
153
|
+
* passed to the modal for dynamic content.
|
|
154
|
+
*
|
|
155
|
+
* @param options - Modal configuration options
|
|
156
|
+
* @returns Promise that resolves when the modal is displayed
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```typescript
|
|
160
|
+
* await viewSDK.displayModal?.({
|
|
161
|
+
* template: 'ui://widget/settings.html',
|
|
162
|
+
* params: {
|
|
163
|
+
* theme: 'dark',
|
|
164
|
+
* apiKey: 'abc123'
|
|
165
|
+
* }
|
|
166
|
+
* });
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
displayModal?(options: ModalOptions): Promise<void>;
|
|
170
|
+
/**
|
|
171
|
+
* Navigate to a different URL within the application
|
|
172
|
+
*
|
|
173
|
+
* This method triggers navigation in the host environment. The behavior may vary
|
|
174
|
+
* depending on the surface (e.g., full page navigation, iframe navigation, etc.).
|
|
175
|
+
*
|
|
176
|
+
* @param url - The URL to navigate to (can be relative or absolute)
|
|
177
|
+
* @returns Promise that resolves when navigation is initiated
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```typescript
|
|
181
|
+
* await viewSDK.navigateTo?.('/dashboard');
|
|
182
|
+
* await viewSDK.navigateTo?.('https://example.com/page');
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
navigateTo?(url: string): Promise<void>;
|
|
186
|
+
/**
|
|
187
|
+
* Mark the application state as "dirty" (having unsaved changes)
|
|
188
|
+
*
|
|
189
|
+
* This notifies the host that the application has unsaved changes. The host may
|
|
190
|
+
* display a visual indicator (e.g., asterisk in title) and prompt the user before
|
|
191
|
+
* navigating away or closing the application.
|
|
192
|
+
*
|
|
193
|
+
* @returns Promise that resolves when the dirty state is marked
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* // User made changes to a form
|
|
198
|
+
* formInput.addEventListener('input', async () => {
|
|
199
|
+
* await viewSDK.markDirtyState?.();
|
|
200
|
+
* });
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
markDirtyState?(): Promise<void>;
|
|
204
|
+
/**
|
|
205
|
+
* Clear the application's "dirty" state (no unsaved changes)
|
|
206
|
+
*
|
|
207
|
+
* This notifies the host that all changes have been saved. Should be called
|
|
208
|
+
* after successfully persisting data to remove unsaved change indicators.
|
|
209
|
+
*
|
|
210
|
+
* @returns Promise that resolves when the dirty state is cleared
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```typescript
|
|
214
|
+
* // After successfully saving data
|
|
215
|
+
* async function saveForm(data) {
|
|
216
|
+
* await api.save(data);
|
|
217
|
+
* await viewSDK.clearDirtyState?.();
|
|
218
|
+
* }
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
clearDirtyState?(): Promise<void>;
|
|
222
|
+
/**
|
|
223
|
+
* Dispatch a custom event to the host environment
|
|
224
|
+
*
|
|
225
|
+
* This allows the application to send custom events with associated data to the
|
|
226
|
+
* host. The host can listen for these events and respond accordingly.
|
|
227
|
+
*
|
|
228
|
+
* @param event - The event name/type to dispatch
|
|
229
|
+
* @param data - Associated event data as key-value pairs
|
|
230
|
+
* @returns Promise that resolves when the event is dispatched
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* ```typescript
|
|
234
|
+
* await viewSDK.dispatchEvent?.('user-action', {
|
|
235
|
+
* action: 'click',
|
|
236
|
+
* buttonId: 'submit',
|
|
237
|
+
* timestamp: Date.now()
|
|
238
|
+
* });
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
dispatchEvent?(event: string, data: Record<string, unknown>): Promise<void>;
|
|
242
|
+
/**
|
|
243
|
+
* Get UI properties from the host and subscribe to changes
|
|
244
|
+
*
|
|
245
|
+
* Returns an object containing a promise for the initial props and a subscribe
|
|
246
|
+
* function to listen for prop updates. UI props allow the host to configure
|
|
247
|
+
* the application's appearance or behavior dynamically.
|
|
248
|
+
*
|
|
249
|
+
* @returns Object with props promise and subscribe function
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```typescript
|
|
253
|
+
* const uiProps = viewSDK.getUiProps?.();
|
|
254
|
+
*
|
|
255
|
+
* // Get initial props
|
|
256
|
+
* const initialProps = await uiProps.props;
|
|
257
|
+
* console.log('Theme:', initialProps.theme);
|
|
258
|
+
*
|
|
259
|
+
* // Subscribe to prop changes
|
|
260
|
+
* uiProps.subscribe((newProps) => {
|
|
261
|
+
* console.log('Props updated:', newProps);
|
|
262
|
+
* // Update UI based on new props
|
|
263
|
+
* });
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
266
|
+
getUiProps?(): {
|
|
267
|
+
props: Promise<Record<string, unknown>>;
|
|
268
|
+
subscribe: (callback: (props: Record<string, unknown>) => void) => void;
|
|
269
|
+
};
|
|
270
|
+
/**
|
|
271
|
+
* Resize the application viewport
|
|
272
|
+
*
|
|
273
|
+
* Requests the host to resize the application container to the specified dimensions.
|
|
274
|
+
* Useful for adaptive layouts or when content size changes dynamically.
|
|
275
|
+
*
|
|
276
|
+
* @param width - The desired width (e.g., "500px", "100%", "auto")
|
|
277
|
+
* @param height - The desired height (e.g., "300px", "100%", "auto")
|
|
278
|
+
* @returns Promise that resolves when resize is complete
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```typescript
|
|
282
|
+
* // Resize to specific pixel dimensions
|
|
283
|
+
* await viewSDK.resize?.('800px', '600px');
|
|
284
|
+
*
|
|
285
|
+
* // Auto-resize based on content
|
|
286
|
+
* await viewSDK.resize?.('auto', 'auto');
|
|
287
|
+
* ```
|
|
288
|
+
*/
|
|
289
|
+
resize?(width: string, height: string): Promise<void>;
|
|
290
|
+
}
|
|
291
|
+
//# sourceMappingURL=view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../src/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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C;IAE5E;;;;;;;;;;;;;;;;;;;;;;;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;CACtD"}
|
package/dist/view.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/sdk-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.30.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "544598e5263d2ea42f968854afb609359f5053b4"
|
|
35
35
|
}
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,MAAM,WAAW,SAAS;IACzB,mBAAmB,EAAE,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpE,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAA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