deepspace 0.4.0 → 0.4.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/dist/index.d.ts CHANGED
@@ -6230,17 +6230,23 @@ declare function toConnectionStatus(queryStatus: string): ConnectionStatus;
6230
6230
  /**
6231
6231
  * useR2Files — Scoped file storage hook for DeepSpace apps.
6232
6232
  *
6233
- * Provides upload, download, list, and delete for files in R2, scoped to
6234
- * the current app ("self" — uses hostname-based scoping on the server).
6233
+ * Provides upload, download, list, and delete for files in R2.
6234
+ *
6235
+ * Two scopes are supported via the `scope` option:
6236
+ * - `'self'` (default): per-user storage. Reads require auth.
6237
+ * - `'app'`: app-wide storage. Reads are public — the upload URL works
6238
+ * directly as an `<img src>`. Use for avatars, logos, etc.
6235
6239
  *
6236
6240
  * @example
6237
6241
  * ```tsx
6238
- * const { upload, downloadFile, deleteFile, list } = useR2Files()
6242
+ * // Per-user files (default):
6243
+ * const { upload, downloadFile } = useR2Files()
6239
6244
  * await upload(myFile, 'photo.png')
6240
6245
  *
6241
- * const files = await list()
6242
- * await downloadFile(files[0]) // uses originalName automatically
6243
- * await deleteFile(files[0])
6246
+ * // App-shared files (public reads — usable in <img src>):
6247
+ * const { upload } = useR2Files({ scope: 'app' })
6248
+ * const r = await upload(file, `avatars/${userId}.png`)
6249
+ * // r.url is a plain, anon-readable URL.
6244
6250
  * ```
6245
6251
  */
6246
6252
  interface R2UploadResult {
@@ -6314,17 +6320,29 @@ interface UseR2FilesReturn {
6314
6320
  /**
6315
6321
  * Build a plain URL for a file. Accepts an R2FileInfo or a raw key string.
6316
6322
  *
6317
- * **Note**: This URL has no auth token attached. It only works for
6318
- * unauthenticated reads on deployed sites where the prefix is derived
6319
- * from the hostname. For authenticated access, use `downloadFile` or
6320
- * `readFile` instead.
6323
+ * **Note**: This URL has no auth token attached. It works for `'app'`-scope
6324
+ * files (which are publicly readable) but not for `'self'`-scope files —
6325
+ * those require an Authorization header, so use `readFile` / `downloadFile`.
6321
6326
  */
6322
6327
  getUrl: (fileOrKey: R2FileInfo | string) => string;
6323
6328
  /** Whether an upload is currently in progress. */
6324
6329
  isUploading: boolean;
6325
6330
  }
6331
+ /**
6332
+ * Scope controls where files live and who can read them:
6333
+ *
6334
+ * - `'self'` (default) — `apps/<app>/users/<userId>/…`. Per-user storage.
6335
+ * Reads require the caller's auth token; not usable from a plain `<img>`
6336
+ * or unauthenticated browser request.
6337
+ * - `'app'` — `apps/<app>/…`. Shared by everyone in the app. Reads are
6338
+ * public (no auth header needed), so the upload URL works directly as
6339
+ * an `<img src>`. Use this for avatars, logos, attachments, and other
6340
+ * assets meant to be embedded in pages.
6341
+ *
6342
+ * Uploads under `'app'` still require a signed-in user.
6343
+ */
6326
6344
  type R2Scope = {
6327
- scope?: 'self';
6345
+ scope?: 'self' | 'app';
6328
6346
  };
6329
6347
  declare function useR2Files(options?: R2Scope): UseR2FilesReturn;
6330
6348
 
@@ -7429,6 +7447,43 @@ interface ToastProviderProps {
7429
7447
  }
7430
7448
  declare function ToastProvider({ children, position, maxToasts, }: ToastProviderProps): React__default.ReactElement;
7431
7449
 
7450
+ /**
7451
+ * Error decoding + a friendly error screen.
7452
+ *
7453
+ * Production React replaces error text with a numeric code and a docs link
7454
+ * (e.g. `Minified React error #310`), so a developer whose app crashes in a
7455
+ * deployed build sees only the number. `decodeReactError` turns that number
7456
+ * back into a plain-English explanation; `ErrorScreen` renders it. The most
7457
+ * common offenders are the hook-order errors (#300 / #310), which almost
7458
+ * always mean a hook was placed after an early `return`.
7459
+ */
7460
+ interface DecodedReactError {
7461
+ code: number;
7462
+ title: string;
7463
+ explanation: string;
7464
+ hint: string;
7465
+ docsUrl: string;
7466
+ }
7467
+ /**
7468
+ * Decode a (possibly minified) React error into a friendly explanation, or
7469
+ * `null` if it isn't a recognizable React error — in which case the caller
7470
+ * should just show the raw message.
7471
+ */
7472
+ declare function decodeReactError(error: unknown): DecodedReactError | null;
7473
+ interface ErrorScreenProps {
7474
+ /** The thrown value, as caught by an error boundary (often non-Error). */
7475
+ error: unknown;
7476
+ /** Recovery action. Defaults to a full page reload. */
7477
+ onReset?: () => void;
7478
+ }
7479
+ /**
7480
+ * A self-contained crash screen. Renders standalone — it replaces the app
7481
+ * shell when used as a root error boundary, so it must not depend on app
7482
+ * providers (toasts, auth, theme context). It reuses only context-free
7483
+ * primitives and reads its colors from the active theme's CSS variables.
7484
+ */
7485
+ declare function ErrorScreen({ error, onReset }: ErrorScreenProps): react_jsx_runtime.JSX.Element;
7486
+
7432
7487
  interface EmptyStateProps extends React__default.HTMLAttributes<HTMLDivElement> {
7433
7488
  icon?: ReactNode;
7434
7489
  title: string;
@@ -7577,4 +7632,4 @@ interface SearchInputProps extends Omit<React$1.ComponentProps<'input'>, 'type'>
7577
7632
  }
7578
7633
  declare const SearchInput: React$1.ForwardRefExoticComponent<Omit<SearchInputProps, "ref"> & React$1.RefAttributes<HTMLInputElement>>;
7579
7634
 
7580
- export { type AdHocChargeOpts, type AiStreamAction, type AiStreamChunk, Alert, AlertDescription, AlertTitle, AuthGate, type AuthGateProps, AuthOverlay, Avatar, AvatarFallback, AvatarImage, Awareness, type AwarenessState, type AwarenessStates, Badge, type BadgeProps, type BaseMessage, Button, type ButtonProps, type CanvasShapeClient, Card, CardContent, CardDescription, CardFooter, CardGrid, CardHeader, CardTitle, type Channel, type ChannelInvitation, type ChannelMember, type ChargeOnceOpts, type ChargeOnceResult, Checkbox, type ClientMessage, type CollectionSchema, ConfirmModal, type ConnectionAttachment, type ConnectionStatus, type ContentSegment, type ConversationObject, type CronHistoryEntry, type CronTaskState, DEEPSPACE_THEME_PROPERTIES, DEFAULT_USER_COLORS, DeepSpaceAuthProvider, type DeepSpaceThemeConfig, DeepSpaceThemeProvider, type DeepSpaceThemeProviderProps, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, ENV, EmptyDocuments, EmptyError, EmptyItems, EmptyProjects, EmptySearch, EmptyState, EmptyTeam, type Environment, type FetchUserProfile, type FileAttachment, type GamePlayer, GridCard, type GroupedReaction, GuestBanner, type HandlerContext, type InboxEntry, Input, type IntegrationResponse, type JobStatusView, type JobView, Label, type LinkPreviewData, LoadingOverlay, LoadingSpinner, MSG, MSG_AWARENESS, MSG_SYNC, MSG_SYNC_STEP1, MSG_SYNC_STEP2, MSG_SYNC_UPDATE, MSG_YJS_AWARENESS, MSG_YJS_SYNC, type MemberRecord, type Message, type MessageHandlers, type MessageRecord, Modal, type MsgType, type PlanInfo, PlatformContext, type PlatformContextValue, PlatformProvider, type PlatformWSOptions, type PlatformWSResult, type PresencePeerClient, PricingTable, type PricingTablePlan, type PricingTablePrice, type ProductChargeOpts, Progress, type ProtocolMessage, type Purchase, type Query, type R2FileInfo, type R2Scope, type R2UploadResult, ROLES, ROLE_ADMIN, ROLE_ANONYMOUS, ROLE_CONFIG, ROLE_DEFAULT, type Reaction, type ReactionRecord, type ReadCursorRecord, type ReadReceipt, type RecordData, RecordProvider, type RecordProviderProps, RecordScope, type RequestOptions, type Role, type RoomUser, type ScopeEntry, ScopeRegistryProvider, SearchInput, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue, Separator, type ServerMessage, SignedIn, SignedOut, Skeleton, SkeletonAvatar, SkeletonCard, SkeletonList, SkeletonTable, SkeletonText, type SubscribeOpts, type SubscribeResult, type SubscriptionState, type SubscriptionStatus, Switch, type SyncResult, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, ToastProvider, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, type UseCanvasResult, type UseCheckoutOpts, type UseCronMonitorResult, type UseGameRoomResult, type UseJobsResult, type UsePresenceRoomResult, type UseR2FilesReturn, type UseYjsFieldResult, type UseYjsRoomResult, type UseYjsTextResult, type User, type UserCredits, type UserInfo, type UserKarma, type UserProfile, type ViewportClient, applyDeepSpaceTheme, applyUIThemeTokens, authClient, badgeVariants, buttonVariants, clearAuthToken, clearDeepSpaceTheme, clientBuild, cn, createDecoder, createEncoder, decodeAiStreamChunk, detectEnvironment, dispatch, encode, encodeAwarenessMessage, encodeSyncStep1, encodeSyncStep2, encodeUpdate, formatFileSize, formatFullTimestamp, formatMessageTime, getApiUrl, getAuthToken, getAuthUrl, getConversationDisplayName, getConversationParticipantIds, getEnvironmentConfig, getMessageType, getPlatformWorkerUrl, getThreadCounts, getUserColor, groupReactionsForMessage, handleAwarenessMessage, handleSyncMessage, hasContent, integration, isDMConversation, isDarkColor, isImageFile, isLocalDev, isProduction, parseMessageMetadata, parseSseLine, readThemeFromDOM, readVarUint, readVarUint8Array, resetEnvironmentCache, serverBuild, shouldGroupMessages, signIn, signOut, toConnectionStatus, toUint8Array, useAuth, useAuthUser, useCanvas, useChannelMembers, useChannels, useCheckout, useCommunities, useConversation, useConversations, useCronMonitor, useDisplayName, useGameRoom, useInbox, useIsDarkTheme, useJobs, useMessages, useMutations, usePlatform, usePlatformWS, usePosts, usePresence, usePresenceRoom, useQuery, useR2Files, useReactions, useReadReceipts, useRecordContext, useSession, useSubscription, useToast, useUser, useUserLookup, useUsers, useYjsField, useYjsRoom, useYjsText, writeVarUint, writeVarUint8Array };
7635
+ export { type AdHocChargeOpts, type AiStreamAction, type AiStreamChunk, Alert, AlertDescription, AlertTitle, AuthGate, type AuthGateProps, AuthOverlay, Avatar, AvatarFallback, AvatarImage, Awareness, type AwarenessState, type AwarenessStates, Badge, type BadgeProps, type BaseMessage, Button, type ButtonProps, type CanvasShapeClient, Card, CardContent, CardDescription, CardFooter, CardGrid, CardHeader, CardTitle, type Channel, type ChannelInvitation, type ChannelMember, type ChargeOnceOpts, type ChargeOnceResult, Checkbox, type ClientMessage, type CollectionSchema, ConfirmModal, type ConnectionAttachment, type ConnectionStatus, type ContentSegment, type ConversationObject, type CronHistoryEntry, type CronTaskState, DEEPSPACE_THEME_PROPERTIES, DEFAULT_USER_COLORS, type DecodedReactError, DeepSpaceAuthProvider, type DeepSpaceThemeConfig, DeepSpaceThemeProvider, type DeepSpaceThemeProviderProps, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, ENV, EmptyDocuments, EmptyError, EmptyItems, EmptyProjects, EmptySearch, EmptyState, EmptyTeam, type Environment, ErrorScreen, type ErrorScreenProps, type FetchUserProfile, type FileAttachment, type GamePlayer, GridCard, type GroupedReaction, GuestBanner, type HandlerContext, type InboxEntry, Input, type IntegrationResponse, type JobStatusView, type JobView, Label, type LinkPreviewData, LoadingOverlay, LoadingSpinner, MSG, MSG_AWARENESS, MSG_SYNC, MSG_SYNC_STEP1, MSG_SYNC_STEP2, MSG_SYNC_UPDATE, MSG_YJS_AWARENESS, MSG_YJS_SYNC, type MemberRecord, type Message, type MessageHandlers, type MessageRecord, Modal, type MsgType, type PlanInfo, PlatformContext, type PlatformContextValue, PlatformProvider, type PlatformWSOptions, type PlatformWSResult, type PresencePeerClient, PricingTable, type PricingTablePlan, type PricingTablePrice, type ProductChargeOpts, Progress, type ProtocolMessage, type Purchase, type Query, type R2FileInfo, type R2Scope, type R2UploadResult, ROLES, ROLE_ADMIN, ROLE_ANONYMOUS, ROLE_CONFIG, ROLE_DEFAULT, type Reaction, type ReactionRecord, type ReadCursorRecord, type ReadReceipt, type RecordData, RecordProvider, type RecordProviderProps, RecordScope, type RequestOptions, type Role, type RoomUser, type ScopeEntry, ScopeRegistryProvider, SearchInput, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue, Separator, type ServerMessage, SignedIn, SignedOut, Skeleton, SkeletonAvatar, SkeletonCard, SkeletonList, SkeletonTable, SkeletonText, type SubscribeOpts, type SubscribeResult, type SubscriptionState, type SubscriptionStatus, Switch, type SyncResult, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, ToastProvider, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, type UseCanvasResult, type UseCheckoutOpts, type UseCronMonitorResult, type UseGameRoomResult, type UseJobsResult, type UsePresenceRoomResult, type UseR2FilesReturn, type UseYjsFieldResult, type UseYjsRoomResult, type UseYjsTextResult, type User, type UserCredits, type UserInfo, type UserKarma, type UserProfile, type ViewportClient, applyDeepSpaceTheme, applyUIThemeTokens, authClient, badgeVariants, buttonVariants, clearAuthToken, clearDeepSpaceTheme, clientBuild, cn, createDecoder, createEncoder, decodeAiStreamChunk, decodeReactError, detectEnvironment, dispatch, encode, encodeAwarenessMessage, encodeSyncStep1, encodeSyncStep2, encodeUpdate, formatFileSize, formatFullTimestamp, formatMessageTime, getApiUrl, getAuthToken, getAuthUrl, getConversationDisplayName, getConversationParticipantIds, getEnvironmentConfig, getMessageType, getPlatformWorkerUrl, getThreadCounts, getUserColor, groupReactionsForMessage, handleAwarenessMessage, handleSyncMessage, hasContent, integration, isDMConversation, isDarkColor, isImageFile, isLocalDev, isProduction, parseMessageMetadata, parseSseLine, readThemeFromDOM, readVarUint, readVarUint8Array, resetEnvironmentCache, serverBuild, shouldGroupMessages, signIn, signOut, toConnectionStatus, toUint8Array, useAuth, useAuthUser, useCanvas, useChannelMembers, useChannels, useCheckout, useCommunities, useConversation, useConversations, useCronMonitor, useDisplayName, useGameRoom, useInbox, useIsDarkTheme, useJobs, useMessages, useMutations, usePlatform, usePlatformWS, usePosts, usePresence, usePresenceRoom, useQuery, useR2Files, useReactions, useReadReceipts, useRecordContext, useSession, useSubscription, useToast, useUser, useUserLookup, useUsers, useYjsField, useYjsRoom, useYjsText, writeVarUint, writeVarUint8Array };