sunpeak 0.1.22 → 0.2.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/README.md +18 -77
- package/bin/sunpeak.js +87 -0
- package/dist/index.cjs +828 -1338
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +98 -581
- package/dist/index.d.ts +98 -581
- package/dist/index.js +796 -1314
- package/dist/index.js.map +1 -1
- package/dist/styles/chatgpt/index.css +146 -0
- package/dist/styles/globals.css +220 -0
- package/package.json +34 -36
- package/template/.prettierignore +4 -0
- package/template/.prettierrc +9 -0
- package/template/README.md +47 -0
- package/template/assets/favicon.ico +0 -0
- package/template/components.json +21 -0
- package/template/dev/main.tsx +65 -0
- package/template/dev/styles.css +5 -0
- package/template/eslint.config.cjs +49 -0
- package/template/index.html +13 -0
- package/template/package.json +56 -0
- package/template/src/App.tsx +45 -0
- package/template/src/components/index.ts +2 -0
- package/template/src/components/shadcn/button.tsx +60 -0
- package/template/src/components/shadcn/card.tsx +76 -0
- package/template/src/components/shadcn/carousel.tsx +260 -0
- package/template/src/components/shadcn/index.ts +5 -0
- package/template/src/components/shadcn/label.tsx +24 -0
- package/template/src/components/shadcn/select.tsx +157 -0
- package/template/src/components/sunpeak-card.test.tsx +76 -0
- package/template/src/components/sunpeak-card.tsx +140 -0
- package/template/src/components/sunpeak-carousel.test.tsx +42 -0
- package/template/src/components/sunpeak-carousel.tsx +126 -0
- package/template/src/index.ts +3 -0
- package/template/src/lib/index.ts +1 -0
- package/template/src/lib/utils.ts +6 -0
- package/template/src/styles/chatgpt.css +146 -0
- package/template/src/styles/globals.css +220 -0
- package/template/src/test/setup.ts +37 -0
- package/template/tsconfig.json +32 -0
- package/template/tsconfig.node.json +11 -0
- package/template/tsup.config.ts +23 -0
- package/template/vite.config.ts +35 -0
- package/template/vitest.config.ts +15 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,245 +1,19 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* @default 800
|
|
11
|
-
*/
|
|
12
|
-
maxWidth?: number;
|
|
13
|
-
/**
|
|
14
|
-
* Override the color scheme detection
|
|
15
|
-
* If not provided, uses window.openai.colorScheme
|
|
16
|
-
*/
|
|
17
|
-
mode?: 'light' | 'dark';
|
|
18
|
-
/**
|
|
19
|
-
* Whether to inject MUI's CssBaseline component
|
|
20
|
-
* @default true
|
|
21
|
-
*/
|
|
22
|
-
enableCssBaseline?: boolean;
|
|
23
|
-
}
|
|
24
|
-
interface GenAIRenderProps {
|
|
25
|
-
/**
|
|
26
|
-
* Maximum height from platform (in pixels)
|
|
27
|
-
*/
|
|
28
|
-
maxHeight: number | null;
|
|
29
|
-
/**
|
|
30
|
-
* Color scheme from platform
|
|
31
|
-
*/
|
|
32
|
-
colorScheme: 'light' | 'dark' | null;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* GenAI - Create platform-aware genAI Apps with automatic theming and constraints.
|
|
36
|
-
*
|
|
37
|
-
* This is the single interface for building genAI Apps. It automatically provides:
|
|
38
|
-
* - MUI theming (light/dark mode from platform)
|
|
39
|
-
* - Platform constraints (maxHeight)
|
|
40
|
-
* - Color scheme information
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* ```tsx
|
|
44
|
-
* export const MyApp = GenAI(({ maxHeight, colorScheme }) => (
|
|
45
|
-
* <div>
|
|
46
|
-
* <h2>My App</h2>
|
|
47
|
-
* <p>Theme: {colorScheme}</p>
|
|
48
|
-
* <p>Max height: {maxHeight}px</p>
|
|
49
|
-
* </div>
|
|
50
|
-
* ));
|
|
51
|
-
* ```
|
|
52
|
-
*/
|
|
53
|
-
declare function GenAI(renderFn: (props: GenAIRenderProps) => ReactNode): {
|
|
54
|
-
(props?: GenAIProps): react_jsx_runtime.JSX.Element;
|
|
55
|
-
displayName: string;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
interface ButtonProps extends Omit<ButtonProps$1, 'onClick'> {
|
|
59
|
-
/**
|
|
60
|
-
* Whether to use primary styling (accent color) or secondary (outlined)
|
|
61
|
-
*/
|
|
62
|
-
isPrimary?: boolean;
|
|
63
|
-
/**
|
|
64
|
-
* Click handler (required)
|
|
65
|
-
*/
|
|
66
|
-
onClick: () => void;
|
|
67
|
-
}
|
|
68
|
-
interface CardProps extends Omit<GenAIProps, 'children'>, HTMLAttributes<HTMLDivElement> {
|
|
69
|
-
/**
|
|
70
|
-
* Card content
|
|
71
|
-
*/
|
|
72
|
-
children?: ReactNode;
|
|
73
|
-
/**
|
|
74
|
-
* Image to display at the top of the card
|
|
75
|
-
*/
|
|
76
|
-
image: string;
|
|
77
|
-
/**
|
|
78
|
-
* Alt text for the image
|
|
79
|
-
*/
|
|
80
|
-
imageAlt: string;
|
|
81
|
-
/**
|
|
82
|
-
* Maximum width for the image in pixels
|
|
83
|
-
*/
|
|
84
|
-
imageMaxWidth: number;
|
|
85
|
-
/**
|
|
86
|
-
* Maximum height for the image in pixels
|
|
87
|
-
*/
|
|
88
|
-
imageMaxHeight: number;
|
|
89
|
-
/**
|
|
90
|
-
* Optional header text (title)
|
|
91
|
-
*/
|
|
92
|
-
header?: ReactNode;
|
|
93
|
-
/**
|
|
94
|
-
* Optional metadata text (e.g., rating, category)
|
|
95
|
-
*/
|
|
96
|
-
metadata?: ReactNode;
|
|
97
|
-
/**
|
|
98
|
-
* First action button (0-1)
|
|
99
|
-
*/
|
|
100
|
-
button1?: ButtonProps;
|
|
101
|
-
/**
|
|
102
|
-
* Second action button (0-1)
|
|
103
|
-
*/
|
|
104
|
-
button2?: ButtonProps;
|
|
105
|
-
/**
|
|
106
|
-
* Card variant
|
|
107
|
-
*/
|
|
108
|
-
variant?: 'default' | 'bordered' | 'elevated';
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Card - A responsive card component that adapts to display mode.
|
|
112
|
-
*
|
|
113
|
-
* In inline mode:
|
|
114
|
-
* - Fixed width for carousel consistency
|
|
115
|
-
* - Compact layout optimized for horizontal scrolling
|
|
116
|
-
* - Clickable to request fullscreen mode
|
|
117
|
-
*
|
|
118
|
-
* In fullscreen mode:
|
|
119
|
-
* - Full width layout
|
|
120
|
-
* - Expanded content display
|
|
121
|
-
* - More breathing room for content
|
|
122
|
-
*
|
|
123
|
-
* Design specs:
|
|
124
|
-
* - Image: aspect-square with 24px border radius
|
|
125
|
-
* - Typography: 16px medium for header, 12px for metadata, 14px for description
|
|
126
|
-
* - Spacing: 12px between sections
|
|
127
|
-
* - Max 2 actions in footer (design guideline)
|
|
128
|
-
*/
|
|
129
|
-
declare const Card: ({ children, image, imageAlt, imageMaxWidth, imageMaxHeight, header, metadata, button1, button2, variant, className, onClick, id, ...props }: CardProps) => react_jsx_runtime.JSX.Element;
|
|
130
|
-
|
|
131
|
-
interface CarouselProps extends Omit<GenAIProps, 'children'>, HTMLAttributes<HTMLDivElement> {
|
|
132
|
-
/**
|
|
133
|
-
* Carousel items (typically Card components)
|
|
134
|
-
*/
|
|
135
|
-
children: ReactNode;
|
|
136
|
-
/**
|
|
137
|
-
* Gap between items in pixels
|
|
138
|
-
* @default 16
|
|
139
|
-
*/
|
|
140
|
-
gap?: number;
|
|
141
|
-
/**
|
|
142
|
-
* Show navigation arrows
|
|
143
|
-
* @default true
|
|
144
|
-
*/
|
|
145
|
-
showArrows?: boolean;
|
|
146
|
-
/**
|
|
147
|
-
* Show edge gradients to indicate more content
|
|
148
|
-
* @default true
|
|
149
|
-
*/
|
|
150
|
-
showEdgeGradients?: boolean;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Carousel - MUI-based carousel for displaying cards side-by-side.
|
|
154
|
-
* Follows OpenAI ChatGPT Apps SDK design guidelines.
|
|
155
|
-
*/
|
|
156
|
-
declare const Carousel: ({ children, gap, maxWidth, showArrows, showEdgeGradients, className, ...props }: CarouselProps) => react_jsx_runtime.JSX.Element;
|
|
157
|
-
|
|
158
|
-
type UnknownObject$1 = Record<string, unknown>;
|
|
159
|
-
type Theme$1 = 'light' | 'dark';
|
|
160
|
-
type SafeAreaInsets$1 = {
|
|
161
|
-
top: number;
|
|
162
|
-
bottom: number;
|
|
163
|
-
left: number;
|
|
164
|
-
right: number;
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { ClassValue } from 'clsx';
|
|
4
|
+
|
|
5
|
+
type Theme$1 = "light" | "dark";
|
|
6
|
+
type ThemeProviderProps = {
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
defaultTheme?: Theme$1;
|
|
9
|
+
theme?: Theme$1;
|
|
165
10
|
};
|
|
166
|
-
type
|
|
167
|
-
|
|
11
|
+
type ThemeProviderState = {
|
|
12
|
+
theme: Theme$1;
|
|
168
13
|
};
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
device: {
|
|
172
|
-
type: DeviceType$1;
|
|
173
|
-
};
|
|
174
|
-
capabilities: {
|
|
175
|
-
hover: boolean;
|
|
176
|
-
touch: boolean;
|
|
177
|
-
};
|
|
178
|
-
};
|
|
179
|
-
/** Display mode */
|
|
180
|
-
type DisplayMode$1 = 'pip' | 'inline' | 'fullscreen';
|
|
181
|
-
type RequestDisplayMode$1 = (args: {
|
|
182
|
-
mode: DisplayMode$1;
|
|
183
|
-
}) => Promise<{
|
|
184
|
-
/**
|
|
185
|
-
* The granted display mode. The host may reject the request.
|
|
186
|
-
* For mobile, PiP is always coerced to fullscreen.
|
|
187
|
-
*/
|
|
188
|
-
mode: DisplayMode$1;
|
|
189
|
-
}>;
|
|
190
|
-
type CallToolResponse$1 = {
|
|
191
|
-
result: string;
|
|
192
|
-
};
|
|
193
|
-
/** Calling APIs */
|
|
194
|
-
type CallTool$1 = (name: string, args: Record<string, unknown>) => Promise<CallToolResponse$1>;
|
|
195
|
-
type ChatGPTGlobals<ToolInput = UnknownObject$1, ToolOutput = UnknownObject$1, ToolResponseMetadata = UnknownObject$1, WidgetState = UnknownObject$1> = {
|
|
196
|
-
colorScheme: Theme$1;
|
|
197
|
-
userAgent: UserAgent$1;
|
|
198
|
-
locale: string;
|
|
199
|
-
maxHeight: number;
|
|
200
|
-
displayMode: DisplayMode$1;
|
|
201
|
-
safeArea: SafeArea$1;
|
|
202
|
-
toolInput: ToolInput;
|
|
203
|
-
toolOutput: ToolOutput | null;
|
|
204
|
-
toolResponseMetadata: ToolResponseMetadata | null;
|
|
205
|
-
widgetState: WidgetState | null;
|
|
206
|
-
setWidgetState: (state: WidgetState) => Promise<void>;
|
|
207
|
-
};
|
|
208
|
-
type API = {
|
|
209
|
-
callTool: CallTool$1;
|
|
210
|
-
sendFollowUpMessage: (args: {
|
|
211
|
-
prompt: string;
|
|
212
|
-
}) => Promise<void>;
|
|
213
|
-
openExternal(payload: {
|
|
214
|
-
href: string;
|
|
215
|
-
}): void;
|
|
216
|
-
requestDisplayMode: RequestDisplayMode$1;
|
|
217
|
-
};
|
|
218
|
-
/** Extra events */
|
|
219
|
-
declare const SET_GLOBALS_EVENT_TYPE = "chatgpt:set_globals";
|
|
220
|
-
declare class SetGlobalsEvent extends CustomEvent<{
|
|
221
|
-
globals: Partial<ChatGPTGlobals>;
|
|
222
|
-
}> {
|
|
223
|
-
readonly type = "chatgpt:set_globals";
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Global openai object injected by the web sandbox for communicating with ChatGPT host page.
|
|
227
|
-
*/
|
|
228
|
-
declare global {
|
|
229
|
-
interface Window {
|
|
230
|
-
openai?: API & ChatGPTGlobals;
|
|
231
|
-
}
|
|
232
|
-
interface WindowEventMap {
|
|
233
|
-
[SET_GLOBALS_EVENT_TYPE]: SetGlobalsEvent;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
14
|
+
declare function ThemeProvider({ children, defaultTheme, theme: controlledTheme, ...props }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
|
|
15
|
+
declare const useThemeContext: () => ThemeProviderState;
|
|
236
16
|
|
|
237
|
-
/**
|
|
238
|
-
* Platform-agnostic types for genAI App SDKs
|
|
239
|
-
*
|
|
240
|
-
* These types define a common interface that can be implemented
|
|
241
|
-
* by different platforms (ChatGPT, Gemini, Claude, etc.)
|
|
242
|
-
*/
|
|
243
17
|
type UnknownObject = Record<string, unknown>;
|
|
244
18
|
type Theme = 'light' | 'dark';
|
|
245
19
|
type SafeAreaInsets = {
|
|
@@ -261,7 +35,6 @@ type UserAgent = {
|
|
|
261
35
|
touch: boolean;
|
|
262
36
|
};
|
|
263
37
|
};
|
|
264
|
-
/** Display mode for the app */
|
|
265
38
|
type DisplayMode = 'pip' | 'inline' | 'fullscreen';
|
|
266
39
|
type RequestDisplayMode = (args: {
|
|
267
40
|
mode: DisplayMode;
|
|
@@ -272,13 +45,8 @@ type CallToolResponse = {
|
|
|
272
45
|
result: string;
|
|
273
46
|
};
|
|
274
47
|
type CallTool = (name: string, args: Record<string, unknown>) => Promise<CallToolResponse>;
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
*
|
|
278
|
-
* All genAI platforms should implement this interface to work with Sunpeak components.
|
|
279
|
-
*/
|
|
280
|
-
type PlatformGlobals<ToolInput = UnknownObject, ToolOutput = UnknownObject, ToolResponseMetadata = UnknownObject, WidgetState = UnknownObject> = {
|
|
281
|
-
colorScheme: Theme;
|
|
48
|
+
type OpenAiGlobals<ToolInput = UnknownObject, ToolOutput = UnknownObject, ToolResponseMetadata = UnknownObject, WidgetState = UnknownObject> = {
|
|
49
|
+
theme: Theme;
|
|
282
50
|
userAgent: UserAgent;
|
|
283
51
|
locale: string;
|
|
284
52
|
maxHeight: number;
|
|
@@ -290,10 +58,7 @@ type PlatformGlobals<ToolInput = UnknownObject, ToolOutput = UnknownObject, Tool
|
|
|
290
58
|
widgetState: WidgetState | null;
|
|
291
59
|
setWidgetState: (state: WidgetState) => Promise<void>;
|
|
292
60
|
};
|
|
293
|
-
|
|
294
|
-
* Platform API methods
|
|
295
|
-
*/
|
|
296
|
-
type PlatformAPI = {
|
|
61
|
+
type OpenAiAPI = {
|
|
297
62
|
callTool: CallTool;
|
|
298
63
|
sendFollowUpMessage: (args: {
|
|
299
64
|
prompt: string;
|
|
@@ -303,347 +68,99 @@ type PlatformAPI = {
|
|
|
303
68
|
}): void;
|
|
304
69
|
requestDisplayMode: RequestDisplayMode;
|
|
305
70
|
};
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
interface PlatformAdapter {
|
|
312
|
-
/**
|
|
313
|
-
* Platform identifier (e.g., 'chatgpt', 'gemini', 'claude')
|
|
314
|
-
*/
|
|
315
|
-
readonly name: string;
|
|
316
|
-
/**
|
|
317
|
-
* Check if this platform is available in the current environment
|
|
318
|
-
*/
|
|
319
|
-
isAvailable(): boolean;
|
|
320
|
-
/**
|
|
321
|
-
* Get a specific global value
|
|
322
|
-
*/
|
|
323
|
-
getGlobal<K extends keyof PlatformGlobals>(key: K): PlatformGlobals[K] | null;
|
|
324
|
-
/**
|
|
325
|
-
* Get all platform globals
|
|
326
|
-
*/
|
|
327
|
-
getGlobals(): (PlatformAPI & PlatformGlobals) | null;
|
|
328
|
-
/**
|
|
329
|
-
* Subscribe to changes in platform globals
|
|
330
|
-
* Returns an unsubscribe function
|
|
331
|
-
*/
|
|
332
|
-
subscribe(callback: () => void): () => void;
|
|
333
|
-
}
|
|
334
|
-
/**
|
|
335
|
-
* Platform registry to track supported platforms
|
|
336
|
-
*/
|
|
337
|
-
type PlatformType = 'chatgpt' | 'gemini' | 'claude' | 'custom';
|
|
338
|
-
|
|
339
|
-
interface ChatGPTSimulatorProps {
|
|
340
|
-
/**
|
|
341
|
-
* The component to render in the ChatGPT message
|
|
342
|
-
* Can be a function that receives the selected App UI
|
|
343
|
-
*/
|
|
344
|
-
children: ReactNode | ((uiSimulation: string) => ReactNode);
|
|
345
|
-
/**
|
|
346
|
-
* Initial display mode
|
|
347
|
-
*/
|
|
348
|
-
displayMode?: DisplayMode$1;
|
|
349
|
-
/**
|
|
350
|
-
* Initial color scheme
|
|
351
|
-
*/
|
|
352
|
-
colorScheme?: Theme$1;
|
|
353
|
-
/**
|
|
354
|
-
* Initial tool input
|
|
355
|
-
*/
|
|
356
|
-
toolInput?: Record<string, unknown>;
|
|
357
|
-
/**
|
|
358
|
-
* Initial tool output
|
|
359
|
-
*/
|
|
360
|
-
toolOutput?: Record<string, unknown> | null;
|
|
361
|
-
/**
|
|
362
|
-
* Initial widget state
|
|
363
|
-
*/
|
|
364
|
-
widgetState?: Record<string, unknown> | null;
|
|
365
|
-
/**
|
|
366
|
-
* User message to display above the component
|
|
367
|
-
*/
|
|
368
|
-
userMessage?: string;
|
|
369
|
-
/**
|
|
370
|
-
* Show simulator controls
|
|
371
|
-
*/
|
|
372
|
-
showControls?: boolean;
|
|
373
|
-
/**
|
|
374
|
-
* App UIs for the App UI selector
|
|
375
|
-
*/
|
|
376
|
-
uiSimulations?: string[];
|
|
377
|
-
/**
|
|
378
|
-
* Initial App UI
|
|
379
|
-
*/
|
|
380
|
-
initialUISimulation?: string;
|
|
381
|
-
}
|
|
382
|
-
/**
|
|
383
|
-
* ChatGPT Simulator Component
|
|
384
|
-
*
|
|
385
|
-
* Emulates the ChatGPT environment for testing components locally.
|
|
386
|
-
* Provides window.openai API and renders components in a ChatGPT-like UI.
|
|
387
|
-
*/
|
|
388
|
-
declare function ChatGPTSimulator({ children, displayMode: initialDisplayMode, colorScheme: initialColorScheme, toolInput, toolOutput, widgetState: initialWidgetState, userMessage, showControls, uiSimulations, initialUISimulation, }: ChatGPTSimulatorProps): react_jsx_runtime.JSX.Element;
|
|
389
|
-
|
|
390
|
-
interface PlatformProviderProps {
|
|
391
|
-
/**
|
|
392
|
-
* The platform adapter to use. If not provided, will auto-detect.
|
|
393
|
-
*/
|
|
394
|
-
adapter?: PlatformAdapter;
|
|
395
|
-
/**
|
|
396
|
-
* Platform name to use (e.g., 'chatgpt', 'gemini'). If not provided, will auto-detect.
|
|
397
|
-
*/
|
|
398
|
-
platform?: string;
|
|
399
|
-
children: ReactNode;
|
|
400
|
-
}
|
|
401
|
-
/**
|
|
402
|
-
* Platform Provider
|
|
403
|
-
*
|
|
404
|
-
* Wrap your app with this provider to specify which genAI platform to use.
|
|
405
|
-
* If no platform is specified, it will auto-detect the available platform.
|
|
406
|
-
*
|
|
407
|
-
* @example
|
|
408
|
-
* ```tsx
|
|
409
|
-
* import { PlatformProvider } from 'sunpeak';
|
|
410
|
-
*
|
|
411
|
-
* // Auto-detect platform
|
|
412
|
-
* <PlatformProvider>
|
|
413
|
-
* <App />
|
|
414
|
-
* </PlatformProvider>
|
|
415
|
-
*
|
|
416
|
-
* // Explicitly use ChatGPT
|
|
417
|
-
* <PlatformProvider platform="chatgpt">
|
|
418
|
-
* <App />
|
|
419
|
-
* </PlatformProvider>
|
|
420
|
-
* ```
|
|
421
|
-
*/
|
|
422
|
-
declare function PlatformProvider({ adapter, platform, children }: PlatformProviderProps): react_jsx_runtime.JSX.Element;
|
|
423
|
-
/**
|
|
424
|
-
* Hook to access the current platform adapter
|
|
425
|
-
*
|
|
426
|
-
* Returns null if no platform is available or detected.
|
|
427
|
-
*/
|
|
428
|
-
declare function usePlatform(): PlatformAdapter | null;
|
|
429
|
-
|
|
430
|
-
declare class ChatGPTPlatformAdapter implements PlatformAdapter {
|
|
431
|
-
readonly name = "chatgpt";
|
|
432
|
-
isAvailable(): boolean;
|
|
433
|
-
getGlobal<K extends keyof PlatformGlobals>(key: K): PlatformGlobals[K] | null;
|
|
434
|
-
getGlobals(): ({
|
|
435
|
-
callTool: CallTool$1;
|
|
436
|
-
sendFollowUpMessage: (args: {
|
|
437
|
-
prompt: string;
|
|
438
|
-
}) => Promise<void>;
|
|
439
|
-
openExternal(payload: {
|
|
440
|
-
href: string;
|
|
441
|
-
}): void;
|
|
442
|
-
requestDisplayMode: RequestDisplayMode$1;
|
|
443
|
-
} & ChatGPTGlobals<UnknownObject$1, UnknownObject$1, UnknownObject$1, UnknownObject$1>) | null;
|
|
444
|
-
subscribe(callback: () => void): () => void;
|
|
71
|
+
declare const SET_GLOBALS_EVENT_TYPE = "openai:set_globals";
|
|
72
|
+
declare class SetGlobalsEvent extends CustomEvent<{
|
|
73
|
+
globals: Partial<OpenAiGlobals>;
|
|
74
|
+
}> {
|
|
75
|
+
readonly type = "openai:set_globals";
|
|
445
76
|
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
*
|
|
454
|
-
* Manages multiple platform adapters and auto-detects the active platform.
|
|
455
|
-
*/
|
|
456
|
-
|
|
457
|
-
interface PlatformRegistry {
|
|
458
|
-
/**
|
|
459
|
-
* Register a platform adapter
|
|
460
|
-
*/
|
|
461
|
-
register(adapter: PlatformAdapter): void;
|
|
462
|
-
/**
|
|
463
|
-
* Get a specific platform adapter by name
|
|
464
|
-
*/
|
|
465
|
-
get(name: string): PlatformAdapter | null;
|
|
466
|
-
/**
|
|
467
|
-
* Auto-detect and return the active platform
|
|
468
|
-
* Returns the first available platform in the registry
|
|
469
|
-
*/
|
|
470
|
-
detect(): PlatformAdapter | null;
|
|
471
|
-
/**
|
|
472
|
-
* Get all registered platforms
|
|
473
|
-
*/
|
|
474
|
-
getAll(): PlatformAdapter[];
|
|
77
|
+
declare global {
|
|
78
|
+
interface Window {
|
|
79
|
+
openai: OpenAiAPI & OpenAiGlobals;
|
|
80
|
+
}
|
|
81
|
+
interface WindowEventMap {
|
|
82
|
+
[SET_GLOBALS_EVENT_TYPE]: SetGlobalsEvent;
|
|
83
|
+
}
|
|
475
84
|
}
|
|
476
|
-
/**
|
|
477
|
-
* Create a new platform registry
|
|
478
|
-
*/
|
|
479
|
-
declare function createPlatformRegistry(): PlatformRegistry;
|
|
480
85
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
* @returns The value of the global state, or null if not available
|
|
489
|
-
*
|
|
490
|
-
* @example
|
|
491
|
-
* ```tsx
|
|
492
|
-
* function MyWidget() {
|
|
493
|
-
* const colorScheme = usePlatformGlobal('colorScheme');
|
|
494
|
-
* const displayMode = usePlatformGlobal('displayMode');
|
|
495
|
-
*
|
|
496
|
-
* return <div className={colorScheme === 'dark' ? 'dark' : 'light'}>...</div>;
|
|
497
|
-
* }
|
|
498
|
-
* ```
|
|
499
|
-
*/
|
|
500
|
-
declare function usePlatformGlobal<K extends keyof PlatformGlobals>(key: K): PlatformGlobals[K] | null;
|
|
86
|
+
type ScreenWidth = 'mobile-s' | 'mobile-l' | 'tablet' | 'full';
|
|
87
|
+
type SimulatorConfig = {
|
|
88
|
+
theme: Theme;
|
|
89
|
+
displayMode: DisplayMode;
|
|
90
|
+
screenWidth: ScreenWidth;
|
|
91
|
+
};
|
|
92
|
+
declare const SCREEN_WIDTHS: Record<ScreenWidth, number>;
|
|
501
93
|
|
|
502
|
-
|
|
503
|
-
* Hook to get the current display mode from the active genAI platform.
|
|
504
|
-
* Display modes include: 'inline', 'fullscreen', and 'pip' (picture-in-picture).
|
|
505
|
-
*
|
|
506
|
-
* Works with any supported genAI platform (ChatGPT, Gemini, Claude, etc.)
|
|
507
|
-
*
|
|
508
|
-
* @returns The current display mode, or null if not in a supported environment
|
|
509
|
-
*/
|
|
510
|
-
declare const useDisplayMode: () => DisplayMode$1 | null;
|
|
94
|
+
declare const useDisplayMode: () => DisplayMode | null;
|
|
511
95
|
|
|
512
|
-
/**
|
|
513
|
-
* Hook to get the maximum height constraint from the active genAI platform.
|
|
514
|
-
* Useful for ensuring your widget doesn't exceed the available space.
|
|
515
|
-
*
|
|
516
|
-
* Works with any supported genAI platform (ChatGPT, Gemini, Claude, etc.)
|
|
517
|
-
*
|
|
518
|
-
* @returns The maximum height in pixels, or null if not available
|
|
519
|
-
*/
|
|
520
96
|
declare const useMaxHeight: () => number | null;
|
|
521
97
|
|
|
522
|
-
|
|
523
|
-
* Hook to request a specific display mode from the platform
|
|
524
|
-
*
|
|
525
|
-
* @example
|
|
526
|
-
* ```tsx
|
|
527
|
-
* const requestDisplayMode = useRequestDisplayMode();
|
|
528
|
-
*
|
|
529
|
-
* const handleClick = async () => {
|
|
530
|
-
* await requestDisplayMode({ mode: 'fullscreen' });
|
|
531
|
-
* };
|
|
532
|
-
* ```
|
|
533
|
-
*/
|
|
534
|
-
declare function useRequestDisplayMode(): RequestDisplayMode$1;
|
|
98
|
+
declare function useIsMobile(): boolean;
|
|
535
99
|
|
|
536
|
-
|
|
537
|
-
* Hook to get the current color scheme from the active genAI platform.
|
|
538
|
-
* Color scheme can be 'light' or 'dark'.
|
|
539
|
-
*
|
|
540
|
-
* Works with any supported genAI platform (ChatGPT, Gemini, Claude, etc.)
|
|
541
|
-
*
|
|
542
|
-
* @returns The current color scheme, or null if not in a supported environment
|
|
543
|
-
*/
|
|
544
|
-
declare const useColorScheme: () => Theme$1 | null;
|
|
100
|
+
declare function useOpenAiGlobal<K extends keyof OpenAiGlobals>(key: K): OpenAiGlobals[K] | null;
|
|
545
101
|
|
|
546
|
-
|
|
547
|
-
* Hook to get widget props (tool output) from the active genAI platform.
|
|
548
|
-
* This contains the data returned by your server's tool.
|
|
549
|
-
*
|
|
550
|
-
* Works with any supported genAI platform (ChatGPT, Gemini, Claude, etc.)
|
|
551
|
-
*
|
|
552
|
-
* @param defaultState - Default state to use if no props are available
|
|
553
|
-
* @returns The widget props from the tool output
|
|
554
|
-
*/
|
|
555
|
-
declare function useWidgetProps<T extends Record<string, unknown>>(defaultState?: T | (() => T)): T;
|
|
102
|
+
declare const useTheme: () => Theme | null;
|
|
556
103
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
* Works with any supported genAI platform (ChatGPT, Gemini, Claude, etc.)
|
|
562
|
-
*
|
|
563
|
-
* @param defaultState - Default state value or function to generate it
|
|
564
|
-
* @returns A tuple of [state, setState] similar to useState
|
|
565
|
-
*/
|
|
566
|
-
declare function useWidgetState<T extends UnknownObject$1>(defaultState: T | (() => T)): readonly [T, (state: SetStateAction<T>) => void];
|
|
567
|
-
declare function useWidgetState<T extends UnknownObject$1>(defaultState?: T | (() => T | null) | null): readonly [T | null, (state: SetStateAction<T | null>) => void];
|
|
104
|
+
declare function useWidgetState<T extends UnknownObject = UnknownObject>(): [
|
|
105
|
+
T | null,
|
|
106
|
+
(state: T) => Promise<void>
|
|
107
|
+
];
|
|
568
108
|
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
109
|
+
interface ChatGPTSimulatorProps {
|
|
110
|
+
children: React.ReactNode;
|
|
111
|
+
appName?: string;
|
|
112
|
+
appIcon?: string;
|
|
113
|
+
userMessage?: string;
|
|
114
|
+
}
|
|
115
|
+
declare function ChatGPTSimulator({ children, appName, appIcon, userMessage }: ChatGPTSimulatorProps): react_jsx_runtime.JSX.Element;
|
|
116
|
+
|
|
117
|
+
declare class MockOpenAI implements OpenAiAPI, OpenAiGlobals {
|
|
118
|
+
theme: Theme;
|
|
119
|
+
userAgent: {
|
|
120
|
+
device: {
|
|
121
|
+
type: "desktop";
|
|
122
|
+
};
|
|
123
|
+
capabilities: {
|
|
124
|
+
hover: boolean;
|
|
125
|
+
touch: boolean;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
locale: string;
|
|
129
|
+
maxHeight: number;
|
|
130
|
+
displayMode: DisplayMode;
|
|
131
|
+
safeArea: {
|
|
132
|
+
insets: {
|
|
133
|
+
top: number;
|
|
134
|
+
bottom: number;
|
|
135
|
+
left: number;
|
|
136
|
+
right: number;
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
toolInput: {};
|
|
140
|
+
toolOutput: null;
|
|
141
|
+
toolResponseMetadata: null;
|
|
142
|
+
widgetState: Record<string, unknown> | null;
|
|
143
|
+
callTool(name: string, args: Record<string, unknown>): Promise<{
|
|
144
|
+
result: string;
|
|
145
|
+
}>;
|
|
146
|
+
sendFollowUpMessage(args: {
|
|
147
|
+
prompt: string;
|
|
148
|
+
}): Promise<void>;
|
|
149
|
+
openExternal(payload: {
|
|
150
|
+
href: string;
|
|
151
|
+
}): void;
|
|
152
|
+
requestDisplayMode(args: {
|
|
153
|
+
mode: DisplayMode;
|
|
154
|
+
}): Promise<{
|
|
155
|
+
mode: DisplayMode;
|
|
156
|
+
}>;
|
|
157
|
+
setWidgetState(state: Record<string, unknown>): Promise<void>;
|
|
158
|
+
setTheme(theme: Theme): void;
|
|
159
|
+
setDisplayMode(displayMode: DisplayMode): void;
|
|
160
|
+
private emitUpdate;
|
|
161
|
+
}
|
|
162
|
+
declare function initMockOpenAI(): MockOpenAI;
|
|
617
163
|
|
|
618
|
-
|
|
619
|
-
* Platform identifier type
|
|
620
|
-
*/
|
|
621
|
-
type Platform = 'chatgpt';
|
|
622
|
-
/**
|
|
623
|
-
* Get the current platform
|
|
624
|
-
* Currently only supports 'chatgpt'
|
|
625
|
-
* Future: Can be extended to support multiple platforms via build-time configuration
|
|
626
|
-
*/
|
|
627
|
-
declare const getCurrentPlatform: () => Platform;
|
|
628
|
-
/**
|
|
629
|
-
* Theme getter function type
|
|
630
|
-
*/
|
|
631
|
-
type ThemeGetter = (mode: 'light' | 'dark') => Theme$2;
|
|
632
|
-
/**
|
|
633
|
-
* Get theme for current platform
|
|
634
|
-
* This is the main function used by components
|
|
635
|
-
*
|
|
636
|
-
* @param mode - Light or dark mode
|
|
637
|
-
* @returns MUI Theme object for the current platform
|
|
638
|
-
*/
|
|
639
|
-
declare const getTheme: (mode: "light" | "dark") => Theme$2;
|
|
640
|
-
/**
|
|
641
|
-
* Get light theme for current platform
|
|
642
|
-
*/
|
|
643
|
-
declare const getLightTheme: () => Theme$2;
|
|
644
|
-
/**
|
|
645
|
-
* Get dark theme for current platform
|
|
646
|
-
*/
|
|
647
|
-
declare const getDarkTheme: () => Theme$2;
|
|
164
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
648
165
|
|
|
649
|
-
export { type
|
|
166
|
+
export { type CallTool, type CallToolResponse, ChatGPTSimulator, type DeviceType, type DisplayMode, type OpenAiAPI, type OpenAiGlobals, type RequestDisplayMode, SCREEN_WIDTHS, SET_GLOBALS_EVENT_TYPE, type SafeArea, type SafeAreaInsets, type ScreenWidth, SetGlobalsEvent, type SimulatorConfig, type Theme, ThemeProvider, type UnknownObject, type UserAgent, cn, initMockOpenAI, useDisplayMode, useIsMobile, useMaxHeight, useOpenAiGlobal, useTheme, useThemeContext, useWidgetState };
|