sunpeak 0.2.6 → 0.3.3

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.
Files changed (79) hide show
  1. package/README.md +32 -17
  2. package/dist/chatgpt/chatgpt-simulator-types.d.ts +8 -0
  3. package/dist/chatgpt/chatgpt-simulator.d.ts +11 -0
  4. package/dist/chatgpt/conversation.d.ts +11 -0
  5. package/dist/chatgpt/index.d.ts +3 -0
  6. package/dist/chatgpt/mcp-provider.d.ts +25 -0
  7. package/dist/chatgpt/mock-openai.d.ts +61 -0
  8. package/dist/chatgpt/openai-provider.d.ts +19 -0
  9. package/dist/chatgpt/openai-types.d.ts +81 -0
  10. package/dist/chatgpt/simple-sidebar.d.ts +22 -0
  11. package/dist/chatgpt/theme-provider.d.ts +13 -0
  12. package/dist/hooks/index.d.ts +14 -0
  13. package/dist/hooks/use-display-mode.d.ts +2 -0
  14. package/dist/hooks/use-locale.d.ts +1 -0
  15. package/dist/hooks/use-max-height.d.ts +1 -0
  16. package/dist/hooks/use-mobile.d.ts +1 -0
  17. package/dist/hooks/use-safe-area.d.ts +2 -0
  18. package/dist/hooks/use-theme.d.ts +2 -0
  19. package/dist/hooks/use-tool-input.d.ts +2 -0
  20. package/dist/hooks/use-tool-response-metadata.d.ts +2 -0
  21. package/dist/hooks/use-user-agent.d.ts +2 -0
  22. package/dist/hooks/use-view.d.ts +2 -0
  23. package/dist/hooks/use-widget-api.d.ts +8 -0
  24. package/dist/hooks/use-widget-global.d.ts +9 -0
  25. package/dist/hooks/use-widget-props.d.ts +1 -0
  26. package/dist/hooks/use-widget-state.d.ts +4 -0
  27. package/dist/index.cjs +3310 -666
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.ts +5 -366
  30. package/dist/index.js +3325 -640
  31. package/dist/index.js.map +1 -1
  32. package/dist/lib/index.d.ts +2 -0
  33. package/dist/lib/media-queries.d.ts +3 -0
  34. package/dist/lib/utils.d.ts +2 -0
  35. package/dist/mcp/index.cjs +799 -64
  36. package/dist/mcp/index.cjs.map +1 -1
  37. package/dist/mcp/index.d.ts +1 -12
  38. package/dist/mcp/index.js +786 -44
  39. package/dist/mcp/index.js.map +1 -1
  40. package/dist/mcp/server.d.ts +10 -0
  41. package/dist/mcp/types.d.ts +74 -0
  42. package/dist/providers/index.d.ts +40 -0
  43. package/dist/providers/types.d.ts +71 -0
  44. package/dist/style.css +5279 -0
  45. package/dist/test/setup.d.ts +0 -0
  46. package/dist/types/index.d.ts +2 -0
  47. package/package.json +15 -20
  48. package/template/README.md +3 -6
  49. package/template/dev/main.tsx +0 -1
  50. package/template/mcp/server.ts +1 -1
  51. package/template/package.json +4 -14
  52. package/template/src/App.tsx +7 -8
  53. package/template/src/components/index.ts +2 -2
  54. package/template/src/components/openai-card.test.tsx +73 -0
  55. package/template/src/components/openai-card.tsx +126 -0
  56. package/template/src/components/openai-carousel.test.tsx +84 -0
  57. package/template/src/components/openai-carousel.tsx +178 -0
  58. package/template/src/styles/globals.css +5 -216
  59. package/template/vite.config.build.ts +61 -0
  60. package/template/vite.config.ts +0 -2
  61. package/dist/index.d.cts +0 -366
  62. package/dist/mcp/index.d.cts +0 -12
  63. package/dist/styles/chatgpt/index.css +0 -146
  64. package/dist/styles/globals.css +0 -219
  65. package/template/components.json +0 -21
  66. package/template/dev/styles.css +0 -6
  67. package/template/postcss.config.js +0 -5
  68. package/template/src/components/shadcn/button.tsx +0 -60
  69. package/template/src/components/shadcn/card.tsx +0 -76
  70. package/template/src/components/shadcn/carousel.tsx +0 -260
  71. package/template/src/components/shadcn/index.ts +0 -5
  72. package/template/src/components/shadcn/label.tsx +0 -24
  73. package/template/src/components/shadcn/select.tsx +0 -157
  74. package/template/src/components/sunpeak-card.test.tsx +0 -76
  75. package/template/src/components/sunpeak-card.tsx +0 -171
  76. package/template/src/components/sunpeak-carousel.test.tsx +0 -42
  77. package/template/src/components/sunpeak-carousel.tsx +0 -160
  78. package/template/src/styles/chatgpt.css +0 -146
  79. package/template/tsup.config.ts +0 -50
package/dist/index.d.ts CHANGED
@@ -1,366 +1,5 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import * as React from 'react';
3
- import { SetStateAction } from 'react';
4
- import { ClassValue } from 'clsx';
5
-
6
- type Theme$1 = "light" | "dark";
7
- type ThemeProviderProps = {
8
- children: React.ReactNode;
9
- defaultTheme?: Theme$1;
10
- theme?: Theme$1;
11
- };
12
- type ThemeProviderState = {
13
- theme: Theme$1;
14
- };
15
- declare function ThemeProvider({ children, defaultTheme, theme: controlledTheme, ...props }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
16
- declare const useThemeContext: () => ThemeProviderState;
17
-
18
- type UnknownObject = Record<string, unknown>;
19
- type Theme = 'light' | 'dark';
20
- type SafeAreaInsets = {
21
- top: number;
22
- bottom: number;
23
- left: number;
24
- right: number;
25
- };
26
- type SafeArea = {
27
- insets: SafeAreaInsets;
28
- };
29
- type DeviceType = 'mobile' | 'tablet' | 'desktop' | 'unknown';
30
- type UserAgent = {
31
- device: {
32
- type: DeviceType;
33
- };
34
- capabilities: {
35
- hover: boolean;
36
- touch: boolean;
37
- };
38
- };
39
- type DisplayMode = 'pip' | 'inline' | 'fullscreen';
40
- type RequestDisplayMode = (args: {
41
- mode: DisplayMode;
42
- }) => Promise<{
43
- mode: DisplayMode;
44
- }>;
45
- type ViewMode = 'modal' | 'default';
46
- type View = {
47
- mode: ViewMode;
48
- params?: UnknownObject;
49
- };
50
- type CallToolResponse = {
51
- result: string;
52
- };
53
- type CallTool = (name: string, args: Record<string, unknown>) => Promise<CallToolResponse>;
54
- type OpenAiGlobals<ToolInput = UnknownObject, ToolOutput = UnknownObject, ToolResponseMetadata = UnknownObject, WidgetState = UnknownObject> = {
55
- theme: Theme;
56
- userAgent: UserAgent;
57
- locale: string;
58
- maxHeight: number;
59
- displayMode: DisplayMode;
60
- safeArea: SafeArea;
61
- view: View | null;
62
- toolInput: ToolInput;
63
- toolOutput: ToolOutput | null;
64
- toolResponseMetadata: ToolResponseMetadata | null;
65
- widgetState: WidgetState | null;
66
- setWidgetState: (state: WidgetState) => Promise<void>;
67
- };
68
- type RequestModal = (args: {
69
- mode: ViewMode;
70
- params?: UnknownObject;
71
- }) => Promise<void>;
72
- type NotifyIntrinsicHeight = (height: number) => void;
73
- type OpenAiAPI = {
74
- callTool: CallTool;
75
- sendFollowUpMessage: (args: {
76
- prompt: string;
77
- }) => Promise<void>;
78
- openExternal(payload: {
79
- href: string;
80
- }): void;
81
- requestDisplayMode: RequestDisplayMode;
82
- requestModal: RequestModal;
83
- notifyIntrinsicHeight: NotifyIntrinsicHeight;
84
- };
85
- declare const SET_GLOBALS_EVENT_TYPE = "openai:set_globals";
86
- declare class SetGlobalsEvent extends CustomEvent<{
87
- globals: Partial<OpenAiGlobals>;
88
- }> {
89
- readonly type = "openai:set_globals";
90
- }
91
- declare global {
92
- interface Window {
93
- openai: OpenAiAPI & OpenAiGlobals;
94
- }
95
- interface WindowEventMap {
96
- [SET_GLOBALS_EVENT_TYPE]: SetGlobalsEvent;
97
- }
98
- }
99
-
100
- /**
101
- * Provider-agnostic types for widget runtime environments.
102
- * These types abstract away the specific host (OpenAI/ChatGPT, etc.)
103
- */
104
-
105
- /**
106
- * Global state available from the widget runtime environment.
107
- * This is a provider-agnostic alias for OpenAiGlobals.
108
- */
109
- type WidgetGlobals<ToolInput = UnknownObject, ToolOutput = UnknownObject, ToolResponseMetadata = UnknownObject, WidgetState = UnknownObject> = {
110
- theme: Theme;
111
- userAgent: UserAgent;
112
- locale: string;
113
- maxHeight: number;
114
- displayMode: DisplayMode;
115
- safeArea: SafeArea;
116
- view: View | null;
117
- toolInput: ToolInput;
118
- toolOutput: ToolOutput | null;
119
- toolResponseMetadata: ToolResponseMetadata | null;
120
- widgetState: WidgetState | null;
121
- setWidgetState: (state: WidgetState) => Promise<void>;
122
- };
123
- /**
124
- * API methods available from the widget runtime environment.
125
- * This is a provider-agnostic alias for OpenAiAPI.
126
- */
127
- type WidgetAPI = {
128
- callTool?: (name: string, args: Record<string, unknown>) => Promise<CallToolResponse>;
129
- sendFollowUpMessage?: (args: {
130
- prompt: string;
131
- }) => Promise<void>;
132
- openExternal?: (payload: {
133
- href: string;
134
- }) => void;
135
- requestDisplayMode?: (args: {
136
- mode: DisplayMode;
137
- }) => Promise<{
138
- mode: DisplayMode;
139
- }>;
140
- requestModal?: (args: {
141
- mode: ViewMode;
142
- params?: UnknownObject;
143
- }) => Promise<void>;
144
- notifyIntrinsicHeight?: (height: number) => void;
145
- setWidgetState?: (state: UnknownObject) => Promise<void>;
146
- };
147
- /**
148
- * Provider interface that abstracts the widget runtime environment.
149
- * Each host (OpenAI, etc.) implements this interface.
150
- */
151
- interface WidgetProvider {
152
- /**
153
- * Unique identifier for the provider.
154
- */
155
- readonly id: string;
156
- /**
157
- * Get the current value of a global property.
158
- */
159
- getGlobal<K extends keyof WidgetGlobals>(key: K): WidgetGlobals[K] | null;
160
- /**
161
- * Subscribe to changes for a specific global property.
162
- * Returns an unsubscribe function.
163
- */
164
- subscribe(key: keyof WidgetGlobals, onChange: () => void): () => void;
165
- /**
166
- * Get the API methods, or null if not available.
167
- */
168
- getAPI(): WidgetAPI | null;
169
- }
170
-
171
- /**
172
- * OpenAI/ChatGPT provider implementation.
173
- * Bridges the OpenAI-specific window.openai API to the provider-agnostic interface.
174
- */
175
-
176
- /**
177
- * Check if the OpenAI provider is available.
178
- */
179
- declare function isOpenAiAvailable(): boolean;
180
- /**
181
- * OpenAI provider implementation.
182
- */
183
- declare class OpenAiProvider implements WidgetProvider {
184
- readonly id = "openai";
185
- getGlobal<K extends keyof WidgetGlobals>(key: K): WidgetGlobals[K] | null;
186
- subscribe(key: keyof WidgetGlobals, onChange: () => void): () => void;
187
- getAPI(): WidgetAPI | null;
188
- }
189
- /**
190
- * Get the OpenAI provider instance (singleton).
191
- */
192
- declare function getOpenAiProvider(): OpenAiProvider;
193
-
194
- /**
195
- * Provider detection and routing.
196
- *
197
- * This module automatically detects which widget runtime environment is available
198
- * and provides the appropriate provider. The detection happens once on first access,
199
- * and subsequent calls return the cached provider directly.
200
- */
201
-
202
- /**
203
- * Detect and return the appropriate provider for the current environment.
204
- * This function caches the result, so detection only happens once.
205
- *
206
- * @returns The detected provider, or null if no provider is available.
207
- */
208
- declare function getProvider(): WidgetProvider | null;
209
- /**
210
- * Check if any provider is available.
211
- */
212
- declare function isProviderAvailable(): boolean;
213
- /**
214
- * Get a global value from the detected provider.
215
- *
216
- * @param key - The global property key to retrieve.
217
- * @returns The value, or null if not available.
218
- */
219
- declare function getGlobal<K extends keyof WidgetGlobals>(key: K): WidgetGlobals[K] | null;
220
- /**
221
- * Subscribe to changes for a global property.
222
- *
223
- * @param key - The global property key to subscribe to.
224
- * @param onChange - Callback to invoke when the value changes.
225
- * @returns An unsubscribe function.
226
- */
227
- declare function subscribeToGlobal(key: keyof WidgetGlobals, onChange: () => void): () => void;
228
- /**
229
- * Get the API from the detected provider.
230
- *
231
- * @returns The API object, or null if not available.
232
- */
233
- declare function getAPI(): WidgetAPI | null;
234
- /**
235
- * Reset the provider detection cache.
236
- * Useful for testing or when the environment changes.
237
- */
238
- declare function resetProviderCache(): void;
239
-
240
- /**
241
- * Hook to read and subscribe to a global property from the widget runtime.
242
- * Automatically detects and uses the appropriate provider (OpenAI, etc.).
243
- *
244
- * @param key - The global property key to read.
245
- * @returns The current value, or null if not available.
246
- */
247
- declare function useWidgetGlobal<K extends keyof WidgetGlobals>(key: K): WidgetGlobals[K] | null;
248
-
249
- /**
250
- * Hook to get the widget runtime API.
251
- * Automatically detects and uses the appropriate provider (OpenAI, etc.).
252
- *
253
- * @returns The API object, or null if not available.
254
- */
255
- declare function useWidgetAPI(): WidgetAPI | null;
256
-
257
- type ScreenWidth = 'mobile-s' | 'mobile-l' | 'tablet' | 'full';
258
- type SimulatorConfig = {
259
- theme: Theme;
260
- displayMode: DisplayMode;
261
- screenWidth: ScreenWidth;
262
- };
263
- declare const SCREEN_WIDTHS: Record<ScreenWidth, number>;
264
-
265
- declare const useDisplayMode: () => DisplayMode | null;
266
-
267
- declare const useLocale: () => string | null;
268
-
269
- declare const useMaxHeight: () => number | null;
270
-
271
- declare function useIsMobile(): boolean;
272
-
273
- declare const useSafeArea: () => SafeArea | null;
274
-
275
- declare const useTheme: () => Theme | null;
276
-
277
- declare function useToolInput<T extends UnknownObject = UnknownObject>(): T | null;
278
-
279
- declare function useToolResponseMetadata<T extends UnknownObject = UnknownObject>(): T | null;
280
-
281
- declare const useUserAgent: () => UserAgent | null;
282
-
283
- declare function useView(): View | null;
284
-
285
- declare function useWidgetProps<T extends Record<string, unknown>>(defaultState?: T | (() => T)): T;
286
-
287
- declare function useWidgetState<T extends UnknownObject>(defaultState: T | (() => T)): readonly [T, (state: SetStateAction<T>) => void];
288
- declare function useWidgetState<T extends UnknownObject>(defaultState?: T | (() => T | null) | null): readonly [T | null, (state: SetStateAction<T | null>) => void];
289
-
290
- interface ChatGPTSimulatorProps {
291
- children: React.ReactNode;
292
- appName?: string;
293
- appIcon?: string;
294
- userMessage?: string;
295
- toolOutput?: Record<string, unknown> | null;
296
- widgetState?: Record<string, unknown> | null;
297
- }
298
- declare function ChatGPTSimulator({ children, appName, appIcon, userMessage, toolOutput, widgetState, }: ChatGPTSimulatorProps): react_jsx_runtime.JSX.Element;
299
-
300
- declare class MockOpenAI implements OpenAiAPI, OpenAiGlobals {
301
- theme: Theme;
302
- userAgent: {
303
- device: {
304
- type: "desktop";
305
- };
306
- capabilities: {
307
- hover: boolean;
308
- touch: boolean;
309
- };
310
- };
311
- locale: string;
312
- maxHeight: number;
313
- displayMode: DisplayMode;
314
- safeArea: {
315
- insets: {
316
- top: number;
317
- bottom: number;
318
- left: number;
319
- right: number;
320
- };
321
- };
322
- view: View | null;
323
- toolInput: Record<string, unknown>;
324
- toolOutput: Record<string, unknown> | null;
325
- toolResponseMetadata: Record<string, unknown> | null;
326
- widgetState: Record<string, unknown> | null;
327
- callTool(name: string, args: Record<string, unknown>): Promise<{
328
- result: string;
329
- }>;
330
- sendFollowUpMessage(args: {
331
- prompt: string;
332
- }): Promise<void>;
333
- openExternal(payload: {
334
- href: string;
335
- }): void;
336
- requestDisplayMode(args: {
337
- mode: DisplayMode;
338
- }): Promise<{
339
- mode: DisplayMode;
340
- }>;
341
- requestModal(args: {
342
- mode: ViewMode;
343
- params?: UnknownObject;
344
- }): Promise<void>;
345
- notifyIntrinsicHeight(height: number): void;
346
- setWidgetState(state: Record<string, unknown>): Promise<void>;
347
- setTheme(theme: Theme): void;
348
- setDisplayMode(displayMode: DisplayMode): void;
349
- setToolOutput(toolOutput: Record<string, unknown> | null): void;
350
- setWidgetStateExternal(widgetState: Record<string, unknown> | null): void;
351
- emitUpdate(globals: Partial<OpenAiGlobals>): void;
352
- }
353
- declare function initMockOpenAI(initialData?: {
354
- theme?: Theme;
355
- displayMode?: DisplayMode;
356
- toolOutput?: Record<string, unknown> | null;
357
- widgetState?: Record<string, unknown> | null;
358
- }): MockOpenAI;
359
-
360
- declare function cn(...inputs: ClassValue[]): string;
361
-
362
- declare const prefersReducedMotion: () => boolean;
363
- declare const isPrimarilyTouchDevice: () => boolean;
364
- declare const isHoverAvailable: () => boolean;
365
-
366
- export { type CallTool, type CallToolResponse, ChatGPTSimulator, type DeviceType, type DisplayMode, type NotifyIntrinsicHeight, type OpenAiAPI, type OpenAiGlobals, type RequestDisplayMode, type RequestModal, SCREEN_WIDTHS, SET_GLOBALS_EVENT_TYPE, type SafeArea, type SafeAreaInsets, type ScreenWidth, SetGlobalsEvent, type SimulatorConfig, type Theme, ThemeProvider, type UnknownObject, type UserAgent, type View, type ViewMode, type WidgetAPI, type WidgetGlobals, type WidgetProvider, cn, getAPI, getGlobal, getOpenAiProvider, getProvider, initMockOpenAI, isHoverAvailable, isOpenAiAvailable, isPrimarilyTouchDevice, isProviderAvailable, prefersReducedMotion, resetProviderCache, subscribeToGlobal, useDisplayMode, useIsMobile, useLocale, useMaxHeight, useSafeArea, useTheme, useThemeContext, useToolInput, useToolResponseMetadata, useUserAgent, useView, useWidgetAPI, useWidgetGlobal, useWidgetProps, useWidgetState };
1
+ export * from './hooks';
2
+ export * from './chatgpt';
3
+ export * from './types';
4
+ export * from './lib';
5
+ export * from './providers';