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.
- package/README.md +32 -17
- package/dist/chatgpt/chatgpt-simulator-types.d.ts +8 -0
- package/dist/chatgpt/chatgpt-simulator.d.ts +11 -0
- package/dist/chatgpt/conversation.d.ts +11 -0
- package/dist/chatgpt/index.d.ts +3 -0
- package/dist/chatgpt/mcp-provider.d.ts +25 -0
- package/dist/chatgpt/mock-openai.d.ts +61 -0
- package/dist/chatgpt/openai-provider.d.ts +19 -0
- package/dist/chatgpt/openai-types.d.ts +81 -0
- package/dist/chatgpt/simple-sidebar.d.ts +22 -0
- package/dist/chatgpt/theme-provider.d.ts +13 -0
- package/dist/hooks/index.d.ts +14 -0
- package/dist/hooks/use-display-mode.d.ts +2 -0
- package/dist/hooks/use-locale.d.ts +1 -0
- package/dist/hooks/use-max-height.d.ts +1 -0
- package/dist/hooks/use-mobile.d.ts +1 -0
- package/dist/hooks/use-safe-area.d.ts +2 -0
- package/dist/hooks/use-theme.d.ts +2 -0
- package/dist/hooks/use-tool-input.d.ts +2 -0
- package/dist/hooks/use-tool-response-metadata.d.ts +2 -0
- package/dist/hooks/use-user-agent.d.ts +2 -0
- package/dist/hooks/use-view.d.ts +2 -0
- package/dist/hooks/use-widget-api.d.ts +8 -0
- package/dist/hooks/use-widget-global.d.ts +9 -0
- package/dist/hooks/use-widget-props.d.ts +1 -0
- package/dist/hooks/use-widget-state.d.ts +4 -0
- package/dist/index.cjs +3310 -666
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -366
- package/dist/index.js +3325 -640
- package/dist/index.js.map +1 -1
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/media-queries.d.ts +3 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/mcp/index.cjs +799 -64
- package/dist/mcp/index.cjs.map +1 -1
- package/dist/mcp/index.d.ts +1 -12
- package/dist/mcp/index.js +786 -44
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/server.d.ts +10 -0
- package/dist/mcp/types.d.ts +74 -0
- package/dist/providers/index.d.ts +40 -0
- package/dist/providers/types.d.ts +71 -0
- package/dist/style.css +5279 -0
- package/dist/test/setup.d.ts +0 -0
- package/dist/types/index.d.ts +2 -0
- package/package.json +15 -20
- package/template/README.md +3 -6
- package/template/dev/main.tsx +0 -1
- package/template/mcp/server.ts +1 -1
- package/template/package.json +4 -14
- package/template/src/App.tsx +7 -8
- package/template/src/components/index.ts +2 -2
- package/template/src/components/openai-card.test.tsx +73 -0
- package/template/src/components/openai-card.tsx +126 -0
- package/template/src/components/openai-carousel.test.tsx +84 -0
- package/template/src/components/openai-carousel.tsx +178 -0
- package/template/src/styles/globals.css +5 -216
- package/template/vite.config.build.ts +61 -0
- package/template/vite.config.ts +0 -2
- package/dist/index.d.cts +0 -366
- package/dist/mcp/index.d.cts +0 -12
- package/dist/styles/chatgpt/index.css +0 -146
- package/dist/styles/globals.css +0 -219
- package/template/components.json +0 -21
- package/template/dev/styles.css +0 -6
- package/template/postcss.config.js +0 -5
- package/template/src/components/shadcn/button.tsx +0 -60
- package/template/src/components/shadcn/card.tsx +0 -76
- package/template/src/components/shadcn/carousel.tsx +0 -260
- package/template/src/components/shadcn/index.ts +0 -5
- package/template/src/components/shadcn/label.tsx +0 -24
- package/template/src/components/shadcn/select.tsx +0 -157
- package/template/src/components/sunpeak-card.test.tsx +0 -76
- package/template/src/components/sunpeak-card.tsx +0 -171
- package/template/src/components/sunpeak-carousel.test.tsx +0 -42
- package/template/src/components/sunpeak-carousel.tsx +0 -160
- package/template/src/styles/chatgpt.css +0 -146
- package/template/tsup.config.ts +0 -50
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import useEmblaCarousel from "embla-carousel-react"
|
|
3
|
+
import { WheelGesturesPlugin } from "embla-carousel-wheel-gestures"
|
|
4
|
+
import { ArrowLeft, ArrowRight } from "@openai/apps-sdk-ui/components/Icon"
|
|
5
|
+
import { useWidgetState, useDisplayMode } from "sunpeak"
|
|
6
|
+
import { Button } from "@openai/apps-sdk-ui/components/Button"
|
|
7
|
+
import { cn } from "@/lib/index"
|
|
8
|
+
|
|
9
|
+
export interface OpenAICarouselState extends Record<string, unknown> {
|
|
10
|
+
currentIndex?: number
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type OpenAICarouselProps = {
|
|
14
|
+
children?: React.ReactNode
|
|
15
|
+
gap?: number
|
|
16
|
+
showArrows?: boolean
|
|
17
|
+
showEdgeGradients?: boolean
|
|
18
|
+
cardWidth?: number | { inline?: number; fullscreen?: number }
|
|
19
|
+
className?: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const OpenAICarousel = React.forwardRef<
|
|
23
|
+
HTMLDivElement,
|
|
24
|
+
OpenAICarouselProps
|
|
25
|
+
>(
|
|
26
|
+
(
|
|
27
|
+
{
|
|
28
|
+
children,
|
|
29
|
+
gap = 16,
|
|
30
|
+
showArrows = true,
|
|
31
|
+
showEdgeGradients = true,
|
|
32
|
+
cardWidth,
|
|
33
|
+
className,
|
|
34
|
+
},
|
|
35
|
+
ref
|
|
36
|
+
) => {
|
|
37
|
+
const [widgetState, setWidgetState] = useWidgetState<OpenAICarouselState>(() => ({
|
|
38
|
+
currentIndex: 0,
|
|
39
|
+
}))
|
|
40
|
+
const displayMode = useDisplayMode()
|
|
41
|
+
|
|
42
|
+
const [emblaRef, emblaApi] = useEmblaCarousel(
|
|
43
|
+
{
|
|
44
|
+
align: "start",
|
|
45
|
+
dragFree: true,
|
|
46
|
+
containScroll: "trimSnaps",
|
|
47
|
+
},
|
|
48
|
+
[WheelGesturesPlugin()]
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
const [canScrollPrev, setCanScrollPrev] = React.useState(false)
|
|
52
|
+
const [canScrollNext, setCanScrollNext] = React.useState(false)
|
|
53
|
+
|
|
54
|
+
const scrollPrev = React.useCallback(() => {
|
|
55
|
+
if (emblaApi) emblaApi.scrollPrev()
|
|
56
|
+
}, [emblaApi])
|
|
57
|
+
|
|
58
|
+
const scrollNext = React.useCallback(() => {
|
|
59
|
+
if (emblaApi) emblaApi.scrollNext()
|
|
60
|
+
}, [emblaApi])
|
|
61
|
+
|
|
62
|
+
const onSelect = React.useCallback(() => {
|
|
63
|
+
if (!emblaApi) return
|
|
64
|
+
|
|
65
|
+
setCanScrollPrev(emblaApi.canScrollPrev())
|
|
66
|
+
setCanScrollNext(emblaApi.canScrollNext())
|
|
67
|
+
|
|
68
|
+
const currentIndex = emblaApi.selectedScrollSnap()
|
|
69
|
+
if (widgetState?.currentIndex !== currentIndex) {
|
|
70
|
+
setWidgetState({ currentIndex })
|
|
71
|
+
}
|
|
72
|
+
}, [emblaApi, widgetState?.currentIndex, setWidgetState])
|
|
73
|
+
|
|
74
|
+
React.useEffect(() => {
|
|
75
|
+
if (!emblaApi) return
|
|
76
|
+
|
|
77
|
+
onSelect()
|
|
78
|
+
emblaApi.on("select", onSelect)
|
|
79
|
+
emblaApi.on("reInit", onSelect)
|
|
80
|
+
|
|
81
|
+
return () => {
|
|
82
|
+
emblaApi.off("select", onSelect)
|
|
83
|
+
emblaApi.off("reInit", onSelect)
|
|
84
|
+
}
|
|
85
|
+
}, [emblaApi, onSelect])
|
|
86
|
+
|
|
87
|
+
const childArray = React.Children.toArray(children)
|
|
88
|
+
|
|
89
|
+
const getCardWidth = () => {
|
|
90
|
+
if (typeof cardWidth === "number") {
|
|
91
|
+
return cardWidth
|
|
92
|
+
}
|
|
93
|
+
if (cardWidth && typeof cardWidth === "object") {
|
|
94
|
+
if (displayMode === "fullscreen" && cardWidth.fullscreen) {
|
|
95
|
+
return cardWidth.fullscreen
|
|
96
|
+
}
|
|
97
|
+
if (cardWidth.inline) {
|
|
98
|
+
return cardWidth.inline
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return 220
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const cardWidthPx = getCardWidth()
|
|
105
|
+
|
|
106
|
+
return (
|
|
107
|
+
<div ref={ref} className={cn("relative w-full", className)}>
|
|
108
|
+
{/* Left edge gradient */}
|
|
109
|
+
{showEdgeGradients && canScrollPrev && (
|
|
110
|
+
<div
|
|
111
|
+
className="pointer-events-none absolute left-0 top-0 z-10 h-full w-12 bg-gradient-to-r from-surface to-transparent"
|
|
112
|
+
aria-hidden="true"
|
|
113
|
+
/>
|
|
114
|
+
)}
|
|
115
|
+
|
|
116
|
+
{/* Right edge gradient */}
|
|
117
|
+
{showEdgeGradients && canScrollNext && (
|
|
118
|
+
<div
|
|
119
|
+
className="pointer-events-none absolute right-0 top-0 z-10 h-full w-12 bg-gradient-to-l from-surface to-transparent"
|
|
120
|
+
aria-hidden="true"
|
|
121
|
+
/>
|
|
122
|
+
)}
|
|
123
|
+
|
|
124
|
+
{/* Carousel viewport */}
|
|
125
|
+
<div ref={emblaRef} className="overflow-hidden w-full">
|
|
126
|
+
<div
|
|
127
|
+
className="flex touch-pan-y"
|
|
128
|
+
style={{
|
|
129
|
+
gap: `${gap}px`,
|
|
130
|
+
marginLeft: `-${gap}px`,
|
|
131
|
+
paddingLeft: `${gap}px`,
|
|
132
|
+
}}
|
|
133
|
+
>
|
|
134
|
+
{childArray.map((child, index) => (
|
|
135
|
+
<div
|
|
136
|
+
key={index}
|
|
137
|
+
className="flex-none"
|
|
138
|
+
style={{
|
|
139
|
+
minWidth: `${cardWidthPx}px`,
|
|
140
|
+
maxWidth: `${cardWidthPx}px`,
|
|
141
|
+
}}
|
|
142
|
+
>
|
|
143
|
+
{child}
|
|
144
|
+
</div>
|
|
145
|
+
))}
|
|
146
|
+
</div>
|
|
147
|
+
</div>
|
|
148
|
+
|
|
149
|
+
{/* Previous button */}
|
|
150
|
+
{showArrows && canScrollPrev && (
|
|
151
|
+
<Button
|
|
152
|
+
variant="soft"
|
|
153
|
+
color="secondary"
|
|
154
|
+
onClick={scrollPrev}
|
|
155
|
+
className="absolute left-2 top-1/2 -translate-y-1/2 z-20 h-8 w-8 min-w-8 rounded-full p-0 shadow-md"
|
|
156
|
+
aria-label="Previous slide"
|
|
157
|
+
>
|
|
158
|
+
<ArrowLeft className="h-4 w-4" />
|
|
159
|
+
</Button>
|
|
160
|
+
)}
|
|
161
|
+
|
|
162
|
+
{/* Next button */}
|
|
163
|
+
{showArrows && canScrollNext && (
|
|
164
|
+
<Button
|
|
165
|
+
variant="soft"
|
|
166
|
+
color="secondary"
|
|
167
|
+
onClick={scrollNext}
|
|
168
|
+
className="absolute right-2 top-1/2 -translate-y-1/2 z-20 h-8 w-8 min-w-8 rounded-full p-0 shadow-md"
|
|
169
|
+
aria-label="Next slide"
|
|
170
|
+
>
|
|
171
|
+
<ArrowRight className="h-4 w-4" />
|
|
172
|
+
</Button>
|
|
173
|
+
)}
|
|
174
|
+
</div>
|
|
175
|
+
)
|
|
176
|
+
}
|
|
177
|
+
)
|
|
178
|
+
OpenAICarousel.displayName = "OpenAICarousel"
|
|
@@ -1,219 +1,8 @@
|
|
|
1
1
|
@import "tailwindcss";
|
|
2
|
+
@import "@openai/apps-sdk-ui/css";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
/* Required for Tailwind to find class references in Apps SDK UI components. */
|
|
5
|
+
@source "../node_modules/@openai/apps-sdk-ui";
|
|
4
6
|
|
|
5
|
-
/*
|
|
6
|
-
@theme
|
|
7
|
-
/* ===================================
|
|
8
|
-
* COLORS - Mapped to shadcn and --sp- variables
|
|
9
|
-
* ===================================
|
|
10
|
-
*/
|
|
11
|
-
--color-*: initial;
|
|
12
|
-
|
|
13
|
-
/* Shadcn colors */
|
|
14
|
-
--color-background: var(--background);
|
|
15
|
-
--color-foreground: var(--foreground);
|
|
16
|
-
--color-border: var(--border);
|
|
17
|
-
--color-card: var(--card);
|
|
18
|
-
--color-card-foreground: var(--card-foreground);
|
|
19
|
-
--color-popover: var(--popover);
|
|
20
|
-
--color-popover-foreground: var(--popover-foreground);
|
|
21
|
-
--color-primary: var(--primary);
|
|
22
|
-
--color-primary-foreground: var(--primary-foreground);
|
|
23
|
-
--color-secondary: var(--secondary);
|
|
24
|
-
--color-secondary-foreground: var(--secondary-foreground);
|
|
25
|
-
--color-muted: var(--muted);
|
|
26
|
-
--color-muted-foreground: var(--muted-foreground);
|
|
27
|
-
--color-accent: var(--accent);
|
|
28
|
-
--color-accent-foreground: var(--accent-foreground);
|
|
29
|
-
--color-destructive: var(--destructive);
|
|
30
|
-
--color-destructive-foreground: var(--destructive-foreground);
|
|
31
|
-
--color-input: var(--input);
|
|
32
|
-
--color-ring: var(--ring);
|
|
33
|
-
|
|
34
|
-
/* Sunpeak semantic colors */
|
|
35
|
-
--color-success: var(--sp-success);
|
|
36
|
-
--color-warning: var(--sp-warning);
|
|
37
|
-
--color-error: var(--sp-error);
|
|
38
|
-
--color-info: var(--sp-info);
|
|
39
|
-
|
|
40
|
-
/* ===================================
|
|
41
|
-
* TYPOGRAPHY - Mapped to --sp- variables
|
|
42
|
-
* ===================================
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
/* Font families */
|
|
46
|
-
--font-sans: var(--sp-font-family);
|
|
47
|
-
|
|
48
|
-
/* Font sizes */
|
|
49
|
-
--text-xs: var(--sp-font-size-xs);
|
|
50
|
-
--text-sm: var(--sp-font-size-sm);
|
|
51
|
-
--text-base: var(--sp-font-size-base);
|
|
52
|
-
--text-lg: var(--sp-font-size-lg);
|
|
53
|
-
--text-xl: var(--sp-font-size-xl);
|
|
54
|
-
|
|
55
|
-
/* Font weights */
|
|
56
|
-
--font-weight-normal: var(--sp-font-weight-normal);
|
|
57
|
-
--font-weight-medium: var(--sp-font-weight-medium);
|
|
58
|
-
--font-weight-semibold: var(--sp-font-weight-semibold);
|
|
59
|
-
--font-weight-bold: var(--sp-font-weight-bold);
|
|
60
|
-
|
|
61
|
-
/* Line heights */
|
|
62
|
-
--leading-tight: var(--sp-line-height-tight);
|
|
63
|
-
--leading-normal: var(--sp-line-height-normal);
|
|
64
|
-
--leading-relaxed: var(--sp-line-height-relaxed);
|
|
65
|
-
|
|
66
|
-
/* ===================================
|
|
67
|
-
* SPACING - Mapped to --sp- variables
|
|
68
|
-
* ===================================
|
|
69
|
-
*/
|
|
70
|
-
--spacing-1: var(--sp-spacing-1);
|
|
71
|
-
--spacing-2: var(--sp-spacing-2);
|
|
72
|
-
--spacing-3: var(--sp-spacing-3);
|
|
73
|
-
--spacing-4: var(--sp-spacing-4);
|
|
74
|
-
--spacing-5: var(--sp-spacing-5);
|
|
75
|
-
--spacing-6: var(--sp-spacing-6);
|
|
76
|
-
--spacing-8: var(--sp-spacing-8);
|
|
77
|
-
|
|
78
|
-
/* ===================================
|
|
79
|
-
* BORDER RADIUS - Mapped to --sp- variables
|
|
80
|
-
* ===================================
|
|
81
|
-
*/
|
|
82
|
-
--radius-sm: var(--sp-radius-sm);
|
|
83
|
-
--radius-md: var(--sp-radius-md);
|
|
84
|
-
--radius-lg: var(--sp-radius-lg);
|
|
85
|
-
--radius-xl: var(--sp-radius-xl);
|
|
86
|
-
--radius-2xl: var(--sp-radius-2xl);
|
|
87
|
-
--radius-full: var(--sp-radius-full);
|
|
88
|
-
|
|
89
|
-
/* ===================================
|
|
90
|
-
* SHADOWS - Mapped to --sp- variables
|
|
91
|
-
* ===================================
|
|
92
|
-
*/
|
|
93
|
-
--shadow-sm: var(--sp-shadow-sm);
|
|
94
|
-
--shadow-md: var(--sp-shadow-md);
|
|
95
|
-
--shadow-lg: var(--sp-shadow-lg);
|
|
96
|
-
--shadow-xl: var(--sp-shadow-xl);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/* ===================================
|
|
100
|
-
* THEME MODE CLASSES
|
|
101
|
-
* ===================================
|
|
102
|
-
* Force light/dark mode on specific elements
|
|
103
|
-
*/
|
|
104
|
-
|
|
105
|
-
.light {
|
|
106
|
-
--sp-color-bg-primary: var(--sp-light-color-bg-primary);
|
|
107
|
-
--sp-color-bg-secondary: var(--sp-light-color-bg-secondary);
|
|
108
|
-
--sp-color-bg-tertiary: var(--sp-light-color-bg-tertiary);
|
|
109
|
-
--sp-color-text-primary: var(--sp-light-color-text-primary);
|
|
110
|
-
--sp-color-text-secondary: var(--sp-light-color-text-secondary);
|
|
111
|
-
--sp-color-text-tertiary: var(--sp-light-color-text-tertiary);
|
|
112
|
-
--sp-color-text-inverted: var(--sp-light-color-text-inverted);
|
|
113
|
-
--sp-color-border: var(--sp-light-color-border);
|
|
114
|
-
--sp-success: var(--sp-light-success);
|
|
115
|
-
--sp-warning: var(--sp-light-warning);
|
|
116
|
-
--sp-error: var(--sp-light-error);
|
|
117
|
-
--sp-info: var(--sp-light-info);
|
|
118
|
-
--sp-accent: var(--sp-light-accent);
|
|
119
|
-
--sp-accent-hover: var(--sp-light-accent-hover);
|
|
120
|
-
--sp-accent-active: var(--sp-light-accent-active);
|
|
121
|
-
--sp-accent-foreground: var(--sp-light-accent-foreground);
|
|
122
|
-
|
|
123
|
-
/* shadcn/ui light mode variables */
|
|
124
|
-
--background: var(--sp-light-color-bg-primary);
|
|
125
|
-
--foreground: var(--sp-light-color-text-primary);
|
|
126
|
-
--card: var(--sp-light-color-bg-primary);
|
|
127
|
-
--card-foreground: var(--sp-light-color-text-primary);
|
|
128
|
-
--popover: var(--sp-light-color-bg-primary);
|
|
129
|
-
--popover-foreground: var(--sp-light-color-text-primary);
|
|
130
|
-
--primary: var(--sp-light-accent);
|
|
131
|
-
--primary-foreground: var(--sp-accent-foreground);
|
|
132
|
-
--secondary: var(--sp-light-color-bg-secondary);
|
|
133
|
-
--secondary-foreground: var(--sp-light-color-text-primary);
|
|
134
|
-
--muted: var(--sp-light-color-bg-tertiary);
|
|
135
|
-
--muted-foreground: var(--sp-light-color-text-tertiary);
|
|
136
|
-
--accent: var(--sp-light-accent);
|
|
137
|
-
--accent-foreground: var(--sp-accent-foreground);
|
|
138
|
-
--destructive: var(--sp-light-error);
|
|
139
|
-
--destructive-foreground: var(--sp-accent-foreground);
|
|
140
|
-
--border: var(--sp-light-color-border);
|
|
141
|
-
--input: var(--sp-light-color-bg-secondary);
|
|
142
|
-
--ring: var(--sp-light-accent);
|
|
143
|
-
--sidebar: var(--sp-light-sidebar);
|
|
144
|
-
--sidebar-foreground: var(--sp-light-color-text-primary);
|
|
145
|
-
--sidebar-primary: var(--sp-light-accent);
|
|
146
|
-
--sidebar-primary-foreground: var(--sp-light-color-text-primary);
|
|
147
|
-
--sidebar-accent: var(--sp-light-accent);
|
|
148
|
-
--sidebar-accent-foreground: var(--sp-light-color-text-primary);
|
|
149
|
-
--sidebar-border: var(--sp-light-color-border);
|
|
150
|
-
--sidebar-ring: var(--sp-light-accent);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
.dark {
|
|
154
|
-
--sp-color-bg-primary: var(--sp-dark-color-bg-primary);
|
|
155
|
-
--sp-color-bg-secondary: var(--sp-dark-color-bg-secondary);
|
|
156
|
-
--sp-color-bg-tertiary: var(--sp-dark-color-bg-tertiary);
|
|
157
|
-
--sp-color-text-primary: var(--sp-dark-color-text-primary);
|
|
158
|
-
--sp-color-text-secondary: var(--sp-dark-color-text-secondary);
|
|
159
|
-
--sp-color-text-tertiary: var(--sp-dark-color-text-tertiary);
|
|
160
|
-
--sp-color-text-inverted: var(--sp-dark-color-text-inverted);
|
|
161
|
-
--sp-color-border: var(--sp-dark-color-border);
|
|
162
|
-
--sp-success: var(--sp-dark-success);
|
|
163
|
-
--sp-warning: var(--sp-dark-warning);
|
|
164
|
-
--sp-error: var(--sp-dark-error);
|
|
165
|
-
--sp-info: var(--sp-dark-info);
|
|
166
|
-
--sp-accent: var(--sp-dark-accent);
|
|
167
|
-
--sp-accent-hover: var(--sp-dark-accent-hover);
|
|
168
|
-
--sp-accent-active: var(--sp-dark-accent-active);
|
|
169
|
-
--sp-accent-foreground: var(--sp-dark-accent-foreground);
|
|
170
|
-
|
|
171
|
-
/* shadcn/ui dark mode variables */
|
|
172
|
-
--background: var(--sp-dark-color-bg-primary);
|
|
173
|
-
--foreground: var(--sp-dark-color-text-primary);
|
|
174
|
-
--card: var(--sp-dark-color-bg-primary);
|
|
175
|
-
--card-foreground: var(--sp-dark-color-text-primary);
|
|
176
|
-
--popover: var(--sp-dark-color-bg-primary);
|
|
177
|
-
--popover-foreground: var(--sp-dark-color-text-primary);
|
|
178
|
-
--primary: var(--sp-dark-accent);
|
|
179
|
-
--primary-foreground: var(--sp-accent-foreground);
|
|
180
|
-
--secondary: var(--sp-dark-color-bg-secondary);
|
|
181
|
-
--secondary-foreground: var(--sp-dark-color-text-primary);
|
|
182
|
-
--muted: var(--sp-dark-color-bg-tertiary);
|
|
183
|
-
--muted-foreground: var(--sp-dark-color-text-tertiary);
|
|
184
|
-
--accent: var(--sp-dark-accent);
|
|
185
|
-
--accent-foreground: var(--sp-accent-foreground);
|
|
186
|
-
--destructive: var(--sp-dark-error);
|
|
187
|
-
--destructive-foreground: var(--sp-accent-foreground);
|
|
188
|
-
--border: var(--sp-dark-color-border);
|
|
189
|
-
--input: var(--sp-dark-color-bg-secondary);
|
|
190
|
-
--ring: var(--sp-dark-accent);
|
|
191
|
-
--sidebar: var(--sp-dark-sidebar);
|
|
192
|
-
--sidebar-foreground: var(--sp-dark-color-text-primary);
|
|
193
|
-
--sidebar-primary: var(--sp-dark-accent);
|
|
194
|
-
--sidebar-primary-foreground: var(--sp-dark-color-text-primary);
|
|
195
|
-
--sidebar-accent: var(--sp-dark-accent);
|
|
196
|
-
--sidebar-accent-foreground: var(--sp-dark-color-text-primary);
|
|
197
|
-
--sidebar-border: var(--sp-dark-color-border);
|
|
198
|
-
--sidebar-ring: var(--sp-dark-accent);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
@theme inline {
|
|
202
|
-
--color-sidebar: var(--sidebar);
|
|
203
|
-
--color-sidebar-foreground: var(--sidebar-foreground);
|
|
204
|
-
--color-sidebar-primary: var(--sidebar-primary);
|
|
205
|
-
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
|
206
|
-
--color-sidebar-accent: var(--sidebar-accent);
|
|
207
|
-
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
|
208
|
-
--color-sidebar-border: var(--sidebar-border);
|
|
209
|
-
--color-sidebar-ring: var(--sidebar-ring);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
@layer base {
|
|
213
|
-
* {
|
|
214
|
-
@apply border-border outline-ring/50;
|
|
215
|
-
}
|
|
216
|
-
body {
|
|
217
|
-
@apply bg-background text-foreground;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
7
|
+
/* Configure dark mode to use data-theme attribute (OpenAI SDK standard) */
|
|
8
|
+
@custom-variant dark (&:where([data-theme="dark"], [data-theme="dark"] *));
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import react from '@vitejs/plugin-react';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import tailwindcss from '@tailwindcss/vite';
|
|
5
|
+
import { readFileSync, writeFileSync, unlinkSync, existsSync } from 'fs';
|
|
6
|
+
|
|
7
|
+
// Plugin to inline CSS into the JS bundle
|
|
8
|
+
function inlineCssPlugin() {
|
|
9
|
+
return {
|
|
10
|
+
name: 'inline-css',
|
|
11
|
+
closeBundle() {
|
|
12
|
+
const distDir = path.resolve(__dirname, 'dist/chatgpt');
|
|
13
|
+
const jsFile = path.join(distDir, 'index.js');
|
|
14
|
+
const cssFile = path.join(distDir, 'style.css');
|
|
15
|
+
|
|
16
|
+
if (existsSync(cssFile) && existsSync(jsFile)) {
|
|
17
|
+
const css = readFileSync(cssFile, 'utf-8');
|
|
18
|
+
const js = readFileSync(jsFile, 'utf-8');
|
|
19
|
+
|
|
20
|
+
// Inject CSS at the start of the JS file
|
|
21
|
+
const injectCss = `(function(){var s=document.createElement('style');s.textContent=${JSON.stringify(css)};document.head.appendChild(s);})();`;
|
|
22
|
+
writeFileSync(jsFile, injectCss + js);
|
|
23
|
+
|
|
24
|
+
// Remove the separate CSS file
|
|
25
|
+
unlinkSync(cssFile);
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default defineConfig({
|
|
32
|
+
plugins: [react(), tailwindcss(), inlineCssPlugin()],
|
|
33
|
+
define: {
|
|
34
|
+
'process.env.NODE_ENV': JSON.stringify('production'),
|
|
35
|
+
},
|
|
36
|
+
resolve: {
|
|
37
|
+
alias: {
|
|
38
|
+
'@': path.resolve(__dirname, './src'),
|
|
39
|
+
},
|
|
40
|
+
conditions: ['style', 'import', 'module', 'browser', 'default'],
|
|
41
|
+
},
|
|
42
|
+
build: {
|
|
43
|
+
target: 'es2020',
|
|
44
|
+
lib: {
|
|
45
|
+
entry: path.resolve(__dirname, 'src/index.chatgpt.tsx'),
|
|
46
|
+
name: 'SunpeakApp',
|
|
47
|
+
formats: ['iife'],
|
|
48
|
+
fileName: () => 'index.js',
|
|
49
|
+
},
|
|
50
|
+
outDir: 'dist/chatgpt',
|
|
51
|
+
cssCodeSplit: false,
|
|
52
|
+
rollupOptions: {
|
|
53
|
+
output: {
|
|
54
|
+
inlineDynamicImports: true,
|
|
55
|
+
assetFileNames: '[name][extname]',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
minify: true,
|
|
59
|
+
cssMinify: true,
|
|
60
|
+
},
|
|
61
|
+
});
|