create-surf-app 0.1.4 → 0.1.6

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 (77) hide show
  1. package/dist/chunk-AMAMASIV.js +1016 -0
  2. package/dist/cli.js +51 -0
  3. package/dist/index.js +5 -379
  4. package/dist/templates/default/CLAUDE.md +46 -0
  5. package/dist/templates/default/backend/db/index.js +23 -0
  6. package/dist/templates/default/backend/db/schema.js +20 -0
  7. package/dist/templates/{backend → default/backend}/eslint.config.mjs +1 -1
  8. package/dist/templates/default/backend/lib/db.js +67 -0
  9. package/dist/templates/default/backend/package.json +25 -0
  10. package/dist/templates/default/backend/routes/proxy.js +66 -0
  11. package/dist/templates/default/backend/server.js +444 -0
  12. package/dist/templates/default/frontend/components.json +21 -0
  13. package/{templates → dist/templates/default}/frontend/eslint.config.js +1 -1
  14. package/dist/templates/default/frontend/package.json +82 -0
  15. package/dist/templates/default/frontend/src/App.tsx +23 -0
  16. package/dist/templates/default/frontend/src/ErrorBoundary.tsx +106 -0
  17. package/dist/templates/default/frontend/src/components/ui/accordion.tsx +55 -0
  18. package/dist/templates/default/frontend/src/components/ui/alert.tsx +59 -0
  19. package/dist/templates/default/frontend/src/components/ui/aspect-ratio.tsx +5 -0
  20. package/dist/templates/default/frontend/src/components/ui/avatar.tsx +48 -0
  21. package/dist/templates/default/frontend/src/components/ui/badge.tsx +36 -0
  22. package/dist/templates/default/frontend/src/components/ui/breadcrumb.tsx +115 -0
  23. package/dist/templates/default/frontend/src/components/ui/button.tsx +57 -0
  24. package/dist/templates/default/frontend/src/components/ui/calendar.tsx +211 -0
  25. package/dist/templates/default/frontend/src/components/ui/card.tsx +76 -0
  26. package/dist/templates/default/frontend/src/components/ui/carousel.tsx +262 -0
  27. package/dist/templates/default/frontend/src/components/ui/checkbox.tsx +30 -0
  28. package/dist/templates/default/frontend/src/components/ui/collapsible.tsx +9 -0
  29. package/dist/templates/default/frontend/src/components/ui/command.tsx +153 -0
  30. package/dist/templates/default/frontend/src/components/ui/context-menu.tsx +200 -0
  31. package/dist/templates/default/frontend/src/components/ui/dialog.tsx +120 -0
  32. package/dist/templates/default/frontend/src/components/ui/drawer.tsx +118 -0
  33. package/dist/templates/default/frontend/src/components/ui/dropdown-menu.tsx +201 -0
  34. package/dist/templates/default/frontend/src/components/ui/form.tsx +176 -0
  35. package/dist/templates/default/frontend/src/components/ui/hover-card.tsx +29 -0
  36. package/dist/templates/default/frontend/src/components/ui/input.tsx +22 -0
  37. package/dist/templates/default/frontend/src/components/ui/label.tsx +26 -0
  38. package/dist/templates/default/frontend/src/components/ui/menubar.tsx +256 -0
  39. package/dist/templates/default/frontend/src/components/ui/navigation-menu.tsx +128 -0
  40. package/dist/templates/default/frontend/src/components/ui/popover.tsx +33 -0
  41. package/dist/templates/default/frontend/src/components/ui/progress.tsx +26 -0
  42. package/dist/templates/default/frontend/src/components/ui/radio-group.tsx +42 -0
  43. package/dist/templates/default/frontend/src/components/ui/resizable.tsx +43 -0
  44. package/dist/templates/default/frontend/src/components/ui/scroll-area.tsx +46 -0
  45. package/dist/templates/default/frontend/src/components/ui/select.tsx +157 -0
  46. package/dist/templates/default/frontend/src/components/ui/separator.tsx +31 -0
  47. package/dist/templates/default/frontend/src/components/ui/sheet.tsx +140 -0
  48. package/dist/templates/default/frontend/src/components/ui/skeleton.tsx +15 -0
  49. package/dist/templates/default/frontend/src/components/ui/slider.tsx +26 -0
  50. package/dist/templates/default/frontend/src/components/ui/sonner.tsx +29 -0
  51. package/dist/templates/default/frontend/src/components/ui/switch.tsx +29 -0
  52. package/dist/templates/default/frontend/src/components/ui/table.tsx +120 -0
  53. package/dist/templates/default/frontend/src/components/ui/tabs.tsx +53 -0
  54. package/dist/templates/default/frontend/src/components/ui/textarea.tsx +22 -0
  55. package/dist/templates/default/frontend/src/components/ui/toast.tsx +129 -0
  56. package/dist/templates/default/frontend/src/components/ui/toaster.tsx +35 -0
  57. package/dist/templates/default/frontend/src/components/ui/toggle-group.tsx +59 -0
  58. package/dist/templates/default/frontend/src/components/ui/toggle.tsx +43 -0
  59. package/dist/templates/default/frontend/src/components/ui/tooltip.tsx +30 -0
  60. package/dist/templates/default/frontend/src/db/schema.ts +16 -0
  61. package/{templates → dist/templates/default}/frontend/src/entry-client.tsx +11 -8
  62. package/dist/templates/default/frontend/src/hooks/use-toast.ts +95 -0
  63. package/dist/templates/default/frontend/src/index.css +314 -0
  64. package/dist/templates/default/frontend/src/lib/api.ts +31 -0
  65. package/dist/templates/default/frontend/src/lib/fetch.ts +38 -0
  66. package/dist/templates/default/frontend/src/lib/utils.ts +6 -0
  67. package/dist/templates/default/frontend/src/vite-env.d.ts +11 -0
  68. package/dist/templates/default/frontend/tsconfig.json +22 -0
  69. package/dist/templates/default/frontend/vite.config.ts +162 -0
  70. package/package.json +7 -7
  71. package/dist/templates/frontend/eslint.config.js +0 -42
  72. package/dist/templates/frontend/src/entry-client.tsx +0 -109
  73. package/templates/backend/eslint.config.mjs +0 -21
  74. package/templates/frontend/index.html +0 -43
  75. package/templates/frontend/src/entry-server.tsx +0 -13
  76. /package/dist/templates/{frontend → default/frontend}/index.html +0 -0
  77. /package/dist/templates/{frontend → default/frontend}/src/entry-server.tsx +0 -0
@@ -0,0 +1,53 @@
1
+ import * as React from "react"
2
+ import * as TabsPrimitive from "@radix-ui/react-tabs"
3
+
4
+ import { cn } from "@/lib/utils"
5
+
6
+ const Tabs = TabsPrimitive.Root
7
+
8
+ const TabsList = React.forwardRef<
9
+ React.ElementRef<typeof TabsPrimitive.List>,
10
+ React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>
11
+ >(({ className, ...props }, ref) => (
12
+ <TabsPrimitive.List
13
+ ref={ref}
14
+ className={cn(
15
+ "inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",
16
+ className
17
+ )}
18
+ {...props}
19
+ />
20
+ ))
21
+ TabsList.displayName = TabsPrimitive.List.displayName
22
+
23
+ const TabsTrigger = React.forwardRef<
24
+ React.ElementRef<typeof TabsPrimitive.Trigger>,
25
+ React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
26
+ >(({ className, ...props }, ref) => (
27
+ <TabsPrimitive.Trigger
28
+ ref={ref}
29
+ className={cn(
30
+ "inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",
31
+ className
32
+ )}
33
+ {...props}
34
+ />
35
+ ))
36
+ TabsTrigger.displayName = TabsPrimitive.Trigger.displayName
37
+
38
+ const TabsContent = React.forwardRef<
39
+ React.ElementRef<typeof TabsPrimitive.Content>,
40
+ React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
41
+ >(({ className, ...props }, ref) => (
42
+ <TabsPrimitive.Content
43
+ ref={ref}
44
+ className={cn(
45
+ "mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
46
+ className
47
+ )}
48
+ {...props}
49
+ />
50
+ ))
51
+ TabsContent.displayName = TabsPrimitive.Content.displayName
52
+
53
+ export { Tabs, TabsList, TabsTrigger, TabsContent }
@@ -0,0 +1,22 @@
1
+ import * as React from "react"
2
+
3
+ import { cn } from "@/lib/utils"
4
+
5
+ const Textarea = React.forwardRef<
6
+ HTMLTextAreaElement,
7
+ React.ComponentProps<"textarea">
8
+ >(({ className, ...props }, ref) => {
9
+ return (
10
+ <textarea
11
+ className={cn(
12
+ "flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
13
+ className
14
+ )}
15
+ ref={ref}
16
+ {...props}
17
+ />
18
+ )
19
+ })
20
+ Textarea.displayName = "Textarea"
21
+
22
+ export { Textarea }
@@ -0,0 +1,129 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import * as ToastPrimitives from "@radix-ui/react-toast"
5
+ import { cva, type VariantProps } from "class-variance-authority"
6
+ import { X } from "lucide-react"
7
+
8
+ import { cn } from "@/lib/utils"
9
+
10
+ const ToastProvider = ToastPrimitives.Provider
11
+
12
+ const ToastViewport = React.forwardRef<
13
+ React.ElementRef<typeof ToastPrimitives.Viewport>,
14
+ React.ComponentPropsWithoutRef<typeof ToastPrimitives.Viewport>
15
+ >(({ className, ...props }, ref) => (
16
+ <ToastPrimitives.Viewport
17
+ ref={ref}
18
+ className={cn(
19
+ "fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",
20
+ className
21
+ )}
22
+ {...props}
23
+ />
24
+ ))
25
+ ToastViewport.displayName = ToastPrimitives.Viewport.displayName
26
+
27
+ const toastVariants = cva(
28
+ "group pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-md border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",
29
+ {
30
+ variants: {
31
+ variant: {
32
+ default: "border bg-background text-foreground",
33
+ destructive:
34
+ "destructive group border-destructive bg-destructive text-destructive-foreground",
35
+ },
36
+ },
37
+ defaultVariants: {
38
+ variant: "default",
39
+ },
40
+ }
41
+ )
42
+
43
+ const Toast = React.forwardRef<
44
+ React.ElementRef<typeof ToastPrimitives.Root>,
45
+ React.ComponentPropsWithoutRef<typeof ToastPrimitives.Root> &
46
+ VariantProps<typeof toastVariants>
47
+ >(({ className, variant, ...props }, ref) => {
48
+ return (
49
+ <ToastPrimitives.Root
50
+ ref={ref}
51
+ className={cn(toastVariants({ variant }), className)}
52
+ {...props}
53
+ />
54
+ )
55
+ })
56
+ Toast.displayName = ToastPrimitives.Root.displayName
57
+
58
+ const ToastAction = React.forwardRef<
59
+ React.ElementRef<typeof ToastPrimitives.Action>,
60
+ React.ComponentPropsWithoutRef<typeof ToastPrimitives.Action>
61
+ >(({ className, ...props }, ref) => (
62
+ <ToastPrimitives.Action
63
+ ref={ref}
64
+ className={cn(
65
+ "inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",
66
+ className
67
+ )}
68
+ {...props}
69
+ />
70
+ ))
71
+ ToastAction.displayName = ToastPrimitives.Action.displayName
72
+
73
+ const ToastClose = React.forwardRef<
74
+ React.ElementRef<typeof ToastPrimitives.Close>,
75
+ React.ComponentPropsWithoutRef<typeof ToastPrimitives.Close>
76
+ >(({ className, ...props }, ref) => (
77
+ <ToastPrimitives.Close
78
+ ref={ref}
79
+ className={cn(
80
+ "absolute right-1 top-1 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",
81
+ className
82
+ )}
83
+ toast-close=""
84
+ {...props}
85
+ >
86
+ <X className="h-4 w-4" />
87
+ </ToastPrimitives.Close>
88
+ ))
89
+ ToastClose.displayName = ToastPrimitives.Close.displayName
90
+
91
+ const ToastTitle = React.forwardRef<
92
+ React.ElementRef<typeof ToastPrimitives.Title>,
93
+ React.ComponentPropsWithoutRef<typeof ToastPrimitives.Title>
94
+ >(({ className, ...props }, ref) => (
95
+ <ToastPrimitives.Title
96
+ ref={ref}
97
+ className={cn("text-sm font-semibold [&+div]:text-xs", className)}
98
+ {...props}
99
+ />
100
+ ))
101
+ ToastTitle.displayName = ToastPrimitives.Title.displayName
102
+
103
+ const ToastDescription = React.forwardRef<
104
+ React.ElementRef<typeof ToastPrimitives.Description>,
105
+ React.ComponentPropsWithoutRef<typeof ToastPrimitives.Description>
106
+ >(({ className, ...props }, ref) => (
107
+ <ToastPrimitives.Description
108
+ ref={ref}
109
+ className={cn("text-sm opacity-90", className)}
110
+ {...props}
111
+ />
112
+ ))
113
+ ToastDescription.displayName = ToastPrimitives.Description.displayName
114
+
115
+ type ToastProps = React.ComponentPropsWithoutRef<typeof Toast>
116
+
117
+ type ToastActionElement = React.ReactElement<typeof ToastAction>
118
+
119
+ export {
120
+ type ToastProps,
121
+ type ToastActionElement,
122
+ ToastProvider,
123
+ ToastViewport,
124
+ Toast,
125
+ ToastTitle,
126
+ ToastDescription,
127
+ ToastClose,
128
+ ToastAction,
129
+ }
@@ -0,0 +1,35 @@
1
+ "use client"
2
+
3
+ import { useToast } from "@/hooks/use-toast"
4
+ import {
5
+ Toast,
6
+ ToastClose,
7
+ ToastDescription,
8
+ ToastProvider,
9
+ ToastTitle,
10
+ ToastViewport,
11
+ } from "@/components/ui/toast"
12
+
13
+ export function Toaster() {
14
+ const { toasts } = useToast()
15
+
16
+ return (
17
+ <ToastProvider>
18
+ {toasts.map(function ({ id, title, description, action, ...props }) {
19
+ return (
20
+ <Toast key={id} {...props}>
21
+ <div className="grid gap-1">
22
+ {title && <ToastTitle>{title}</ToastTitle>}
23
+ {description && (
24
+ <ToastDescription>{description}</ToastDescription>
25
+ )}
26
+ </div>
27
+ {action}
28
+ <ToastClose />
29
+ </Toast>
30
+ )
31
+ })}
32
+ <ToastViewport />
33
+ </ToastProvider>
34
+ )
35
+ }
@@ -0,0 +1,59 @@
1
+ import * as React from "react"
2
+ import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group"
3
+ import { type VariantProps } from "class-variance-authority"
4
+
5
+ import { cn } from "@/lib/utils"
6
+ import { toggleVariants } from "@/components/ui/toggle"
7
+
8
+ const ToggleGroupContext = React.createContext<
9
+ VariantProps<typeof toggleVariants>
10
+ >({
11
+ size: "default",
12
+ variant: "default",
13
+ })
14
+
15
+ const ToggleGroup = React.forwardRef<
16
+ React.ElementRef<typeof ToggleGroupPrimitive.Root>,
17
+ React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Root> &
18
+ VariantProps<typeof toggleVariants>
19
+ >(({ className, variant, size, children, ...props }, ref) => (
20
+ <ToggleGroupPrimitive.Root
21
+ ref={ref}
22
+ className={cn("flex items-center justify-center gap-1", className)}
23
+ {...props}
24
+ >
25
+ <ToggleGroupContext.Provider value={{ variant, size }}>
26
+ {children}
27
+ </ToggleGroupContext.Provider>
28
+ </ToggleGroupPrimitive.Root>
29
+ ))
30
+
31
+ ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName
32
+
33
+ const ToggleGroupItem = React.forwardRef<
34
+ React.ElementRef<typeof ToggleGroupPrimitive.Item>,
35
+ React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Item> &
36
+ VariantProps<typeof toggleVariants>
37
+ >(({ className, children, variant, size, ...props }, ref) => {
38
+ const context = React.useContext(ToggleGroupContext)
39
+
40
+ return (
41
+ <ToggleGroupPrimitive.Item
42
+ ref={ref}
43
+ className={cn(
44
+ toggleVariants({
45
+ variant: context.variant || variant,
46
+ size: context.size || size,
47
+ }),
48
+ className
49
+ )}
50
+ {...props}
51
+ >
52
+ {children}
53
+ </ToggleGroupPrimitive.Item>
54
+ )
55
+ })
56
+
57
+ ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName
58
+
59
+ export { ToggleGroup, ToggleGroupItem }
@@ -0,0 +1,43 @@
1
+ import * as React from "react"
2
+ import * as TogglePrimitive from "@radix-ui/react-toggle"
3
+ import { cva, type VariantProps } from "class-variance-authority"
4
+
5
+ import { cn } from "@/lib/utils"
6
+
7
+ const toggleVariants = cva(
8
+ "inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
9
+ {
10
+ variants: {
11
+ variant: {
12
+ default: "bg-transparent",
13
+ outline:
14
+ "border border-input bg-transparent shadow-sm hover:bg-accent hover:text-accent-foreground",
15
+ },
16
+ size: {
17
+ default: "h-9 px-2 min-w-9",
18
+ sm: "h-8 px-1.5 min-w-8",
19
+ lg: "h-10 px-2.5 min-w-10",
20
+ },
21
+ },
22
+ defaultVariants: {
23
+ variant: "default",
24
+ size: "default",
25
+ },
26
+ }
27
+ )
28
+
29
+ const Toggle = React.forwardRef<
30
+ React.ElementRef<typeof TogglePrimitive.Root>,
31
+ React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root> &
32
+ VariantProps<typeof toggleVariants>
33
+ >(({ className, variant, size, ...props }, ref) => (
34
+ <TogglePrimitive.Root
35
+ ref={ref}
36
+ className={cn(toggleVariants({ variant, size, className }))}
37
+ {...props}
38
+ />
39
+ ))
40
+
41
+ Toggle.displayName = TogglePrimitive.Root.displayName
42
+
43
+ export { Toggle, toggleVariants }
@@ -0,0 +1,30 @@
1
+ import * as React from "react"
2
+ import * as TooltipPrimitive from "@radix-ui/react-tooltip"
3
+
4
+ import { cn } from "@/lib/utils"
5
+
6
+ const TooltipProvider = TooltipPrimitive.Provider
7
+
8
+ const Tooltip = TooltipPrimitive.Root
9
+
10
+ const TooltipTrigger = TooltipPrimitive.Trigger
11
+
12
+ const TooltipContent = React.forwardRef<
13
+ React.ElementRef<typeof TooltipPrimitive.Content>,
14
+ React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
15
+ >(({ className, sideOffset = 4, ...props }, ref) => (
16
+ <TooltipPrimitive.Portal>
17
+ <TooltipPrimitive.Content
18
+ ref={ref}
19
+ sideOffset={sideOffset}
20
+ className={cn(
21
+ "z-50 w-fit text-balance rounded-[10px] border border-[var(--border-base)] bg-foreground/5 px-3 py-2 text-xs text-[var(--fg-subtle)] backdrop-blur-2xl animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",
22
+ className
23
+ )}
24
+ {...props}
25
+ />
26
+ </TooltipPrimitive.Portal>
27
+ ))
28
+ TooltipContent.displayName = TooltipPrimitive.Content.displayName
29
+
30
+ export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }
@@ -0,0 +1,16 @@
1
+ // Database schema definition — keep in sync with actual DB tables.
2
+ // This file is the single source of truth for table definitions across sessions.
3
+ // After any CREATE TABLE or ALTER TABLE, update this file to match.
4
+ //
5
+ // Example (uncomment and modify when creating tables):
6
+ //
7
+ // export const schema = {
8
+ // todos: {
9
+ // id: 'SERIAL PRIMARY KEY',
10
+ // title: 'TEXT NOT NULL',
11
+ // completed: 'BOOLEAN DEFAULT false',
12
+ // created_at: 'TIMESTAMPTZ DEFAULT NOW()',
13
+ // },
14
+ // } as const
15
+ //
16
+ export {}
@@ -41,6 +41,7 @@ async function boot() {
41
41
  const { createRoot, hydrateRoot } = await import('react-dom/client')
42
42
  const { QueryClient, QueryClientProvider } = await import('@tanstack/react-query')
43
43
  const { default: App } = await import('./App')
44
+ const { default: ErrorBoundary } = await import('./ErrorBoundary')
44
45
 
45
46
  const queryClient = new QueryClient({
46
47
  defaultOptions: { queries: {
@@ -51,8 +52,10 @@ async function boot() {
51
52
  } },
52
53
  })
53
54
 
54
- const children = createElement(QueryClientProvider, { client: queryClient },
55
- createElement(App)
55
+ const children = createElement(ErrorBoundary, null,
56
+ createElement(QueryClientProvider, { client: queryClient },
57
+ createElement(App)
58
+ )
56
59
  )
57
60
 
58
61
  // Use hydrateRoot only when SSR rendered real app content. The scaffold's
@@ -87,9 +90,9 @@ async function boot() {
87
90
 
88
91
  if (count < MAX_RELOADS) {
89
92
  root.innerHTML = [
90
- '<div style=\"padding:24px;text-align:center;font-family:system-ui,sans-serif\">',
91
- '<p style=\"color:#3b82f6;font-weight:600;margin:0 0 4px\">Loading dependencies...</p>',
92
- '<p style=\"color:#3b82f6;opacity:0.7;font-size:12px;margin:0\">Reloading automatically</p>',
93
+ '<div style="padding:24px;text-align:center;font-family:system-ui,sans-serif">',
94
+ '<p style="color:#3b82f6;font-weight:600;margin:0 0 4px">Loading dependencies...</p>',
95
+ '<p style="color:#3b82f6;opacity:0.7;font-size:12px;margin:0">Reloading automatically</p>',
93
96
  '</div>',
94
97
  ].join('')
95
98
  sessionStorage.setItem(RELOAD_KEY, JSON.stringify({ c: count + 1, t: Date.now() }))
@@ -97,9 +100,9 @@ async function boot() {
97
100
  setTimeout(() => location.reload(), 3000 + count * 1000)
98
101
  } else {
99
102
  root.innerHTML = [
100
- '<div style=\"padding:24px;text-align:center;font-family:system-ui,sans-serif\">',
101
- '<p style=\"color:#c0392b;font-weight:600;margin:0 0 4px\">Failed to load dependencies</p>',
102
- '<p style=\"color:#c0392b;opacity:0.8;font-size:12px;margin:0\">Please refresh the page</p>',
103
+ '<div style="padding:24px;text-align:center;font-family:system-ui,sans-serif">',
104
+ '<p style="color:#c0392b;font-weight:600;margin:0 0 4px">Failed to load dependencies</p>',
105
+ '<p style="color:#c0392b;opacity:0.8;font-size:12px;margin:0">Please refresh the page</p>',
103
106
  '</div>',
104
107
  ].join('')
105
108
  }
@@ -0,0 +1,95 @@
1
+ import * as React from "react"
2
+
3
+ const TOAST_LIMIT = 1
4
+ const TOAST_REMOVE_DELAY = 1000000
5
+
6
+ type ToasterToast = {
7
+ id: string
8
+ title?: React.ReactNode
9
+ description?: React.ReactNode
10
+ action?: React.ReactElement
11
+ open?: boolean
12
+ onOpenChange?: (open: boolean) => void
13
+ variant?: "default" | "destructive"
14
+ }
15
+
16
+ const actionTypes = {
17
+ ADD_TOAST: "ADD_TOAST",
18
+ UPDATE_TOAST: "UPDATE_TOAST",
19
+ DISMISS_TOAST: "DISMISS_TOAST",
20
+ REMOVE_TOAST: "REMOVE_TOAST",
21
+ } as const
22
+
23
+ let count = 0
24
+
25
+ function genId() {
26
+ count = (count + 1) % Number.MAX_SAFE_INTEGER
27
+ return count.toString()
28
+ }
29
+
30
+ type Action =
31
+ | { type: typeof actionTypes.ADD_TOAST; toast: ToasterToast }
32
+ | { type: typeof actionTypes.UPDATE_TOAST; toast: Partial<ToasterToast> }
33
+ | { type: typeof actionTypes.DISMISS_TOAST; toastId?: string }
34
+ | { type: typeof actionTypes.REMOVE_TOAST; toastId?: string }
35
+
36
+ interface State {
37
+ toasts: ToasterToast[]
38
+ }
39
+
40
+ const toastTimeouts = new Map<string, ReturnType<typeof setTimeout>>()
41
+
42
+ const addToRemoveQueue = (toastId: string) => {
43
+ if (toastTimeouts.has(toastId)) return
44
+ const timeout = setTimeout(() => {
45
+ toastTimeouts.delete(toastId)
46
+ dispatch({ type: actionTypes.REMOVE_TOAST, toastId })
47
+ }, TOAST_REMOVE_DELAY)
48
+ toastTimeouts.set(toastId, timeout)
49
+ }
50
+
51
+ export const reducer = (state: State, action: Action): State => {
52
+ switch (action.type) {
53
+ case actionTypes.ADD_TOAST:
54
+ return { ...state, toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT) }
55
+ case actionTypes.UPDATE_TOAST:
56
+ return { ...state, toasts: state.toasts.map((t) => (t.id === action.toast.id ? { ...t, ...action.toast } : t)) }
57
+ case actionTypes.DISMISS_TOAST: {
58
+ const { toastId } = action
59
+ if (toastId) addToRemoveQueue(toastId)
60
+ else state.toasts.forEach((t) => addToRemoveQueue(t.id))
61
+ return { ...state, toasts: state.toasts.map((t) => (toastId == null || t.id === toastId ? { ...t, open: false } : t)) }
62
+ }
63
+ case actionTypes.REMOVE_TOAST:
64
+ return { ...state, toasts: action.toastId == null ? [] : state.toasts.filter((t) => t.id !== action.toastId) }
65
+ }
66
+ }
67
+
68
+ const listeners: Array<(state: State) => void> = []
69
+ let memoryState: State = { toasts: [] }
70
+
71
+ function dispatch(action: Action) {
72
+ memoryState = reducer(memoryState, action)
73
+ listeners.forEach((listener) => listener(memoryState))
74
+ }
75
+
76
+ type Toast = Omit<ToasterToast, "id">
77
+
78
+ function toast({ ...props }: Toast) {
79
+ const id = genId()
80
+ const update = (props: ToasterToast) => dispatch({ type: actionTypes.UPDATE_TOAST, toast: { ...props, id } })
81
+ const dismiss = () => dispatch({ type: actionTypes.DISMISS_TOAST, toastId: id })
82
+ dispatch({ type: actionTypes.ADD_TOAST, toast: { ...props, id, open: true, onOpenChange: (open) => { if (!open) dismiss() } } })
83
+ return { id, dismiss, update }
84
+ }
85
+
86
+ function useToast() {
87
+ const [state, setState] = React.useState<State>(memoryState)
88
+ React.useEffect(() => {
89
+ listeners.push(setState)
90
+ return () => { const i = listeners.indexOf(setState); if (i > -1) listeners.splice(i, 1) }
91
+ }, [state])
92
+ return { ...state, toast, dismiss: (toastId?: string) => dispatch({ type: actionTypes.DISMISS_TOAST, toastId }) }
93
+ }
94
+
95
+ export { useToast, toast }