@trycourier/courier-react 8.0.16-beta → 8.0.18-beta

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.
@@ -1,4 +1,4 @@
1
- import { default as React } from 'react';
1
+ import { default as React } from '../../../../node_modules/react';
2
2
  interface CourierClientProps {
3
3
  children: React.ReactNode;
4
4
  }
@@ -1,4 +1,4 @@
1
- import { default as React } from 'react';
1
+ import { default as React } from '../../../../node_modules/react';
2
2
  import { CourierInboxListItemActionFactoryProps, CourierInboxListItemFactoryProps, CourierInboxTheme, CourierInboxHeaderFactoryProps, CourierInboxStateEmptyFactoryProps, CourierInboxStateLoadingFactoryProps, CourierInboxStateErrorFactoryProps, CourierInboxPaginationItemFactoryProps, CourierInboxFeedType } from '@trycourier/courier-ui-inbox';
3
3
  import { CourierComponentThemeMode } from '@trycourier/courier-ui-core';
4
4
  export interface CourierInboxProps {
package/dist/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@trycourier/courier-ui-inbox"),r=require("react"),t=require("@trycourier/courier-js"),s=require("react/jsx-runtime"),n=require("react-dom/client"),o=require("react-dom");function a(e){const r=document.createElement("div");return o.flushSync((()=>{!function(e,r){const t=n.createRoot(r);t.render(e)}(e,r)})),r}const u=({children:e})=>{const[t,n]=r.useState(!1);return r.useEffect((()=>{n(!0)}),[]),"undefined"==typeof window?null:t?s.jsx(s.Fragment,{children:e}):null};exports.CourierInbox=e=>{const t=r.useRef(null);return r.useEffect((()=>{const r=t.current;r&&r.onMessageClick(e.onMessageClick)}),[e.onMessageClick,t]),r.useEffect((()=>{const r=t.current;r&&r.onMessageActionClick(e.onMessageActionClick)}),[e.onMessageActionClick,t]),r.useEffect((()=>{const r=t.current;r&&r.onMessageLongPress(e.onMessageLongPress)}),[e.onMessageLongPress,t]),r.useEffect((()=>{const r=t.current;r&&e.renderHeader&&queueMicrotask((()=>{r.setHeader((r=>a(e.renderHeader(r))))}))}),[e.renderHeader,t]),r.useEffect((()=>{const r=t.current;r&&e.renderListItem&&queueMicrotask((()=>{r.setListItem((r=>a(e.renderListItem(r))))}))}),[e.renderListItem,t]),r.useEffect((()=>{const r=t.current;r&&e.renderEmptyState&&queueMicrotask((()=>{r.setEmptyState((r=>a(e.renderEmptyState(r))))}))}),[e.renderEmptyState,t]),r.useEffect((()=>{const r=t.current;r&&e.renderLoadingState&&queueMicrotask((()=>{r.setLoadingState((r=>a(e.renderLoadingState(r))))}))}),[e.renderLoadingState,t]),r.useEffect((()=>{const r=t.current;r&&e.renderErrorState&&queueMicrotask((()=>{r.setErrorState((r=>a(e.renderErrorState(r))))}))}),[e.renderErrorState,t]),r.useEffect((()=>{const r=t.current;r&&e.renderPaginationItem&&queueMicrotask((()=>{r.setPaginationItem((r=>a(e.renderPaginationItem(r))))}))}),[e.renderPaginationItem,t]),r.useEffect((()=>{const r=t.current;r&&queueMicrotask((()=>{r.setFeedType(e.feedType||"inbox")}))}),[e.feedType,t]),s.jsx(u,{children:s.jsx("courier-inbox",{ref:t,height:e.height,"light-theme":e.lightTheme?JSON.stringify(e.lightTheme):void 0,"dark-theme":e.darkTheme?JSON.stringify(e.darkTheme):void 0,mode:e.mode})})},exports.CourierInboxPopupMenu=e=>{const t=r.useRef(null);return r.useEffect((()=>{const r=t.current;r&&r.onMessageClick(e.onMessageClick)}),[e.onMessageClick,t]),r.useEffect((()=>{const r=t.current;r&&r.onMessageActionClick(e.onMessageActionClick)}),[e.onMessageActionClick,t]),r.useEffect((()=>{const r=t.current;r&&r.onMessageLongPress(e.onMessageLongPress)}),[e.onMessageLongPress,t]),r.useEffect((()=>{const r=t.current;r&&e.renderPopupHeader&&queueMicrotask((()=>{r.setPopupHeader((r=>a(e.renderPopupHeader(r))))}))}),[e.renderPopupHeader,t]),r.useEffect((()=>{const r=t.current;r&&e.renderPopupListItem&&queueMicrotask((()=>{r.setPopupListItem((r=>a(e.renderPopupListItem(r))))}))}),[e.renderPopupListItem,t]),r.useEffect((()=>{const r=t.current;r&&e.renderPopupEmptyState&&queueMicrotask((()=>{r.setPopupEmptyState((r=>a(e.renderPopupEmptyState(r))))}))}),[e.renderPopupEmptyState,t]),r.useEffect((()=>{const r=t.current;r&&e.renderPopupLoadingState&&queueMicrotask((()=>{r.setPopupLoadingState((r=>a(e.renderPopupLoadingState(r))))}))}),[e.renderPopupLoadingState,t]),r.useEffect((()=>{const r=t.current;r&&e.renderPopupErrorState&&queueMicrotask((()=>{r.setPopupErrorState((r=>a(e.renderPopupErrorState(r))))}))}),[e.renderPopupErrorState,t]),r.useEffect((()=>{const r=t.current;r&&e.renderPopupPaginationItem&&queueMicrotask((()=>{r.setPopupPaginationItem((r=>a(e.renderPopupPaginationItem(r))))}))}),[e.renderPopupPaginationItem,t]),r.useEffect((()=>{const r=t.current;r&&e.renderPopupMenuButton&&queueMicrotask((()=>{r.setPopupMenuButton((r=>a(e.renderPopupMenuButton(r))))}))}),[e.renderPopupMenuButton,t]),r.useEffect((()=>{const r=t.current;r&&queueMicrotask((()=>{r.setFeedType(e.feedType||"inbox")}))}),[e.feedType,t]),s.jsx(u,{children:s.jsx("courier-inbox-popup-menu",{ref:t,"popup-alignment":e.popupAlignment,"popup-width":e.popupWidth,"popup-height":e.popupHeight,left:e.left,top:e.top,right:e.right,bottom:e.bottom,"light-theme":e.lightTheme?JSON.stringify(e.lightTheme):void 0,"dark-theme":e.darkTheme?JSON.stringify(e.darkTheme):void 0,mode:e.mode})})},exports.useCourier=()=>{const s=e=>t.Courier.shared.signIn(e),n=()=>t.Courier.shared.signOut(),o=r=>e.CourierInboxDatastore.shared.load(r),a=r=>e.CourierInboxDatastore.shared.fetchNextPageOfMessages(r),u=e=>t.Courier.shared.paginationLimit=e,i=r=>e.CourierInboxDatastore.shared.readMessage({message:r}),c=r=>e.CourierInboxDatastore.shared.unreadMessage({message:r}),d=r=>e.CourierInboxDatastore.shared.clickMessage({message:r}),g=r=>e.CourierInboxDatastore.shared.archiveMessage({message:r}),p=r=>e.CourierInboxDatastore.shared.openMessage({message:r}),f=r=>e.CourierInboxDatastore.shared.unarchiveMessage({message:r}),h=()=>e.CourierInboxDatastore.shared.readAllMessages(),[M,m]=r.useState({userId:void 0,signIn:s,signOut:n}),[l,P]=r.useState({load:o,fetchNextPageOfMessages:a,setPaginationLimit:u,readMessage:i,unreadMessage:c,clickMessage:d,archiveMessage:g,openMessage:p,unarchiveMessage:f,readAllMessages:h});r.useEffect((()=>{const r=t.Courier.shared.addAuthenticationListener((()=>E())),s=new e.CourierInboxDataStoreListener({onError:e=>S(e),onDataSetChange:()=>S(),onPageAdded:()=>S(),onMessageAdd:()=>S(),onMessageRemove:()=>S(),onMessageUpdate:()=>S(),onUnreadCountChange:()=>S()});return e.CourierInboxDatastore.shared.addDataStoreListener(s),E(),S(),()=>{r.remove(),s.remove()}}),[]);const E=()=>{var e;const r=null==(e=t.Courier.shared.client)?void 0:e.options;m({userId:null==r?void 0:r.userId,signIn:s,signOut:n})},S=r=>{const t=e.CourierInboxDatastore.shared;P({load:o,fetchNextPageOfMessages:a,setPaginationLimit:u,readMessage:i,unreadMessage:c,clickMessage:d,archiveMessage:g,openMessage:p,unarchiveMessage:f,readAllMessages:h,inbox:t.inboxDataSet,archive:t.archiveDataSet,unreadCount:t.unreadCount,error:r})};return{shared:t.Courier.shared,auth:M,inbox:l}};
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/utils/utils.tsx","../src/components/courier-client-component.tsx","../src/components/courier-inbox.tsx","../src/components/courier-inbox-popup-menu.tsx","../src/hooks/use-courier.tsx"],"sourcesContent":["import { ReactNode } from \"react\";\nimport { createRoot } from \"react-dom/client\";\nimport { flushSync } from \"react-dom\";\n\n/**\n * Converts a React node to an HTMLElement.\n * This function uses flushSync to ensure the DOM is updated synchronously.\n * @param node - The React node to convert.\n * @returns The converted HTMLElement.\n */\nexport function reactNodeToHTMLElement(node: ReactNode): HTMLElement {\n const container = document.createElement('div');\n\n // Use flushSync to ensure the DOM is updated synchronously\n flushSync(() => {\n render(node, container);\n });\n\n return container;\n}\n\n/**\n * Render a React node using createRoot.\n * @param node - The React node to render.\n * @param container - The container to render the node into.\n * @returns The rendered node.\n */\nfunction render(node: ReactNode, container: HTMLElement) {\n const root = createRoot(container);\n return root.render(node);\n}","import React, { useState, useEffect } from 'react';\n\ninterface CourierClientProps {\n children: React.ReactNode;\n}\n\nexport const CourierClientComponent: React.FC<CourierClientProps> = ({ children }) => {\n const [isMounted, setIsMounted] = useState(false);\n\n useEffect(() => {\n setIsMounted(true);\n }, []);\n\n // During SSR, render nothing or fallback\n if (typeof window === 'undefined') {\n return null;\n }\n\n if (!isMounted) {\n return null;\n }\n\n return <>{children}</>;\n};","import React, { useRef, useEffect } from \"react\";\nimport { CourierInboxListItemActionFactoryProps, CourierInboxListItemFactoryProps, CourierInboxTheme, CourierInbox as CourierInboxElement, CourierInboxHeaderFactoryProps, CourierInboxStateEmptyFactoryProps, CourierInboxStateLoadingFactoryProps, CourierInboxStateErrorFactoryProps, CourierInboxPaginationItemFactoryProps, CourierInboxFeedType } from \"@trycourier/courier-ui-inbox\";\nimport { reactNodeToHTMLElement } from \"../utils/utils\";\nimport { CourierComponentThemeMode } from \"@trycourier/courier-ui-core\";\nimport { CourierClientComponent } from \"./courier-client-component\";\n\nexport interface CourierInboxProps {\n height?: string;\n lightTheme?: CourierInboxTheme;\n darkTheme?: CourierInboxTheme;\n mode?: CourierComponentThemeMode;\n feedType?: CourierInboxFeedType;\n onMessageClick?: (props: CourierInboxListItemFactoryProps) => void;\n onMessageActionClick?: (props: CourierInboxListItemActionFactoryProps) => void;\n onMessageLongPress?: (props: CourierInboxListItemFactoryProps) => void;\n renderHeader?: (props: CourierInboxHeaderFactoryProps | undefined | null) => React.ReactNode;\n renderListItem?: (props: CourierInboxListItemFactoryProps | undefined | null) => React.ReactNode;\n renderEmptyState?: (props: CourierInboxStateEmptyFactoryProps | undefined | null) => React.ReactNode;\n renderLoadingState?: (props: CourierInboxStateLoadingFactoryProps | undefined | null) => React.ReactNode;\n renderErrorState?: (props: CourierInboxStateErrorFactoryProps | undefined | null) => React.ReactNode;\n renderPaginationItem?: (props: CourierInboxPaginationItemFactoryProps | undefined | null) => React.ReactNode;\n}\n\nexport const CourierInbox = (props: CourierInboxProps) => {\n const inboxRef = useRef<CourierInboxElement>(null);\n\n // Handle message click\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n inbox.onMessageClick(props.onMessageClick);\n }, [props.onMessageClick, inboxRef]);\n\n // Handle message action click\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n inbox.onMessageActionClick(props.onMessageActionClick);\n }, [props.onMessageActionClick, inboxRef]);\n\n // Handle message long press\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n inbox.onMessageLongPress(props.onMessageLongPress);\n }, [props.onMessageLongPress, inboxRef]);\n\n // Render header\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderHeader) return;\n queueMicrotask(() => {\n inbox.setHeader((headerProps?: CourierInboxHeaderFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderHeader!(headerProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderHeader, inboxRef]);\n\n // Render list item\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderListItem) return;\n queueMicrotask(() => {\n inbox.setListItem((itemProps?: CourierInboxListItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderListItem!(itemProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderListItem, inboxRef]);\n\n // Render empty state\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderEmptyState) return;\n queueMicrotask(() => {\n inbox.setEmptyState((emptyStateProps?: CourierInboxStateEmptyFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderEmptyState!(emptyStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderEmptyState, inboxRef]);\n\n // Render loading state\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderLoadingState) return;\n queueMicrotask(() => {\n inbox.setLoadingState((loadingStateProps?: CourierInboxStateLoadingFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderLoadingState!(loadingStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderLoadingState, inboxRef]);\n\n // Render error state\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderErrorState) return;\n queueMicrotask(() => {\n inbox.setErrorState((errorStateProps?: CourierInboxStateErrorFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderErrorState!(errorStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderErrorState, inboxRef]);\n\n // Render pagination item\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderPaginationItem) return;\n queueMicrotask(() => {\n inbox.setPaginationItem((paginationProps?: CourierInboxPaginationItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPaginationItem!(paginationProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPaginationItem, inboxRef]);\n\n // Set feed type\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n queueMicrotask(() => {\n inbox.setFeedType(props.feedType || 'inbox');\n });\n }, [props.feedType, inboxRef]);\n\n return (\n <CourierClientComponent>\n {/* @ts-ignore */}\n <courier-inbox\n ref={inboxRef}\n height={props.height}\n light-theme={props.lightTheme ? JSON.stringify(props.lightTheme) : undefined}\n dark-theme={props.darkTheme ? JSON.stringify(props.darkTheme) : undefined}\n mode={props.mode}\n />\n </CourierClientComponent>\n );\n};","import { useRef, useEffect } from \"react\";\nimport { CourierInboxFeedType, CourierInboxHeaderFactoryProps, CourierInboxListItemActionFactoryProps, CourierInboxListItemFactoryProps, CourierInboxMenuButtonFactoryProps, CourierInboxPopupMenu as CourierInboxPopupMenuElement, CourierInboxPaginationItemFactoryProps, CourierInboxPopupAlignment, CourierInboxStateEmptyFactoryProps, CourierInboxStateErrorFactoryProps, CourierInboxStateLoadingFactoryProps, CourierInboxTheme } from \"@trycourier/courier-ui-inbox\";\nimport { reactNodeToHTMLElement } from \"../utils/utils\";\nimport { CourierComponentThemeMode } from \"@trycourier/courier-ui-core\";\nimport { CourierClientComponent } from \"./courier-client-component\";\n\nexport interface CourierInboxPopupMenuProps {\n popupAlignment?: CourierInboxPopupAlignment;\n popupWidth?: string;\n popupHeight?: string;\n left?: string;\n top?: string;\n right?: string;\n bottom?: string;\n lightTheme?: CourierInboxTheme;\n darkTheme?: CourierInboxTheme;\n mode?: CourierComponentThemeMode;\n feedType?: CourierInboxFeedType;\n onMessageClick?: (props: CourierInboxListItemFactoryProps) => void;\n onMessageActionClick?: (props: CourierInboxListItemActionFactoryProps) => void;\n onMessageLongPress?: (props: CourierInboxListItemFactoryProps) => void;\n renderPopupHeader?: (props: CourierInboxHeaderFactoryProps | undefined | null) => React.ReactNode;\n renderPopupListItem?: (props: CourierInboxListItemFactoryProps | undefined | null) => React.ReactNode;\n renderPopupEmptyState?: (props: CourierInboxStateEmptyFactoryProps | undefined | null) => React.ReactNode;\n renderPopupLoadingState?: (props: CourierInboxStateLoadingFactoryProps | undefined | null) => React.ReactNode;\n renderPopupErrorState?: (props: CourierInboxStateErrorFactoryProps | undefined | null) => React.ReactNode;\n renderPopupPaginationItem?: (props: CourierInboxPaginationItemFactoryProps | undefined | null) => React.ReactNode;\n renderPopupMenuButton?: (props: CourierInboxMenuButtonFactoryProps | undefined | null) => React.ReactNode;\n}\n\nexport const CourierInboxPopupMenu = (props: CourierInboxPopupMenuProps) => {\n const menuRef = useRef<CourierInboxPopupMenuElement>(null);\n\n // Handle message click\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu) return;\n menu.onMessageClick(props.onMessageClick);\n }, [props.onMessageClick, menuRef]);\n\n // Handle message action click\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu) return;\n menu.onMessageActionClick(props.onMessageActionClick);\n }, [props.onMessageActionClick, menuRef]);\n\n // Handle message long press\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu) return;\n menu.onMessageLongPress(props.onMessageLongPress);\n }, [props.onMessageLongPress, menuRef]);\n\n // Render header\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderPopupHeader) return;\n queueMicrotask(() => {\n menu.setPopupHeader((headerProps?: CourierInboxHeaderFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPopupHeader!(headerProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPopupHeader, menuRef]);\n\n // Render list item\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderPopupListItem) return;\n queueMicrotask(() => {\n menu.setPopupListItem((itemProps?: CourierInboxListItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPopupListItem!(itemProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPopupListItem, menuRef]);\n\n // Render empty state\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderPopupEmptyState) return;\n queueMicrotask(() => {\n menu.setPopupEmptyState((emptyStateProps?: CourierInboxStateEmptyFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPopupEmptyState!(emptyStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPopupEmptyState, menuRef]);\n\n // Render loading state\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderPopupLoadingState) return;\n queueMicrotask(() => {\n menu.setPopupLoadingState((loadingStateProps?: CourierInboxStateLoadingFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPopupLoadingState!(loadingStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPopupLoadingState, menuRef]);\n\n // Render error state\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderPopupErrorState) return;\n queueMicrotask(() => {\n menu.setPopupErrorState((errorStateProps?: CourierInboxStateErrorFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPopupErrorState!(errorStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPopupErrorState, menuRef]);\n\n // Render pagination item\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderPopupPaginationItem) return;\n queueMicrotask(() => {\n menu.setPopupPaginationItem((paginationProps?: CourierInboxPaginationItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPopupPaginationItem!(paginationProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPopupPaginationItem, menuRef]);\n\n // Render menu button\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderPopupMenuButton) return;\n queueMicrotask(() => {\n menu.setPopupMenuButton((buttonProps?: CourierInboxMenuButtonFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPopupMenuButton!(buttonProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPopupMenuButton, menuRef]);\n\n // Set feed type\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu) return;\n queueMicrotask(() => {\n menu.setFeedType(props.feedType || 'inbox');\n });\n }, [props.feedType, menuRef]);\n\n return (\n <CourierClientComponent>\n {/* @ts-ignore */}\n <courier-inbox-popup-menu\n ref={menuRef}\n popup-alignment={props.popupAlignment}\n popup-width={props.popupWidth}\n popup-height={props.popupHeight}\n left={props.left}\n top={props.top}\n right={props.right}\n bottom={props.bottom}\n light-theme={props.lightTheme ? JSON.stringify(props.lightTheme) : undefined}\n dark-theme={props.darkTheme ? JSON.stringify(props.darkTheme) : undefined}\n mode={props.mode}\n />\n </CourierClientComponent>\n );\n};\n","import React from 'react';\nimport { Courier, CourierProps, InboxMessage } from '@trycourier/courier-js';\nimport { CourierInboxDatastore, CourierInboxDataStoreListener, CourierInboxFeedType, InboxDataSet } from '@trycourier/courier-ui-inbox';\n\ntype AuthenticationHooks = {\n userId?: string,\n signIn: (props: CourierProps) => void,\n signOut: () => void\n}\n\ntype InboxHooks = {\n load: (props?: { feedType: CourierInboxFeedType, canUseCache: boolean }) => Promise<void>,\n fetchNextPageOfMessages: (props: { feedType: CourierInboxFeedType }) => Promise<InboxDataSet | null>,\n setPaginationLimit: (limit: number) => void,\n readMessage: (message: InboxMessage) => Promise<void>,\n unreadMessage: (message: InboxMessage) => Promise<void>,\n clickMessage: (message: InboxMessage) => Promise<void>,\n archiveMessage: (message: InboxMessage) => Promise<void>,\n openMessage: (message: InboxMessage) => Promise<void>,\n unarchiveMessage: (message: InboxMessage) => Promise<void>,\n readAllMessages: () => Promise<void>,\n inbox?: InboxDataSet,\n archive?: InboxDataSet,\n unreadCount?: number,\n error?: Error\n}\n\n// A hook for managing the shared state of Courier\n// If you want to use more functions, checkout the Courier JS SDK which\n// can be used directly by importing from '@trycourier/courier-js'\nexport const useCourier = () => {\n\n // Authentication Functions\n const signIn = (props: CourierProps) => Courier.shared.signIn(props);\n const signOut = () => Courier.shared.signOut();\n\n // Inbox Functions\n const loadInbox = (props?: { feedType: CourierInboxFeedType, canUseCache: boolean }) => CourierInboxDatastore.shared.load(props);\n const fetchNextPageOfMessages = (props: { feedType: CourierInboxFeedType }) => CourierInboxDatastore.shared.fetchNextPageOfMessages(props);\n const setPaginationLimit = (limit: number) => Courier.shared.paginationLimit = limit;\n const readMessage = (message: InboxMessage) => CourierInboxDatastore.shared.readMessage({ message });\n const unreadMessage = (message: InboxMessage) => CourierInboxDatastore.shared.unreadMessage({ message });\n const clickMessage = (message: InboxMessage) => CourierInboxDatastore.shared.clickMessage({ message });\n const archiveMessage = (message: InboxMessage) => CourierInboxDatastore.shared.archiveMessage({ message });\n const openMessage = (message: InboxMessage) => CourierInboxDatastore.shared.openMessage({ message });\n const unarchiveMessage = (message: InboxMessage) => CourierInboxDatastore.shared.unarchiveMessage({ message });\n const readAllMessages = () => CourierInboxDatastore.shared.readAllMessages();\n\n // State\n const [auth, setAuth] = React.useState<AuthenticationHooks>({\n userId: undefined,\n signIn,\n signOut\n });\n\n const [inbox, setInbox] = React.useState<InboxHooks>({\n load: loadInbox,\n fetchNextPageOfMessages,\n setPaginationLimit,\n readMessage,\n unreadMessage,\n clickMessage,\n archiveMessage,\n openMessage,\n unarchiveMessage,\n readAllMessages\n });\n\n React.useEffect(() => {\n\n // Add a listener to the Courier instance\n const listener = Courier.shared.addAuthenticationListener(() => refreshAuth());\n\n // Add inbox data store listener\n const inboxListener = new CourierInboxDataStoreListener({\n onError: (error: Error) => refreshInbox(error),\n onDataSetChange: () => refreshInbox(),\n onPageAdded: () => refreshInbox(),\n onMessageAdd: () => refreshInbox(),\n onMessageRemove: () => refreshInbox(),\n onMessageUpdate: () => refreshInbox(),\n onUnreadCountChange: () => refreshInbox()\n });\n CourierInboxDatastore.shared.addDataStoreListener(inboxListener);\n\n // Set initial values\n refreshAuth();\n refreshInbox();\n\n // Remove listeners when the component unmounts\n return () => {\n listener.remove();\n inboxListener.remove();\n };\n }, []);\n\n const refreshAuth = () => {\n const options = Courier.shared.client?.options;\n setAuth({\n userId: options?.userId,\n signIn,\n signOut\n });\n }\n\n const refreshInbox = (error?: Error) => {\n const datastore = CourierInboxDatastore.shared;\n setInbox({\n load: loadInbox,\n fetchNextPageOfMessages,\n setPaginationLimit,\n readMessage,\n unreadMessage,\n clickMessage,\n archiveMessage,\n openMessage,\n unarchiveMessage,\n readAllMessages,\n inbox: datastore.inboxDataSet,\n archive: datastore.archiveDataSet,\n unreadCount: datastore.unreadCount,\n error: error,\n });\n }\n\n return {\n shared: Courier.shared,\n auth: auth,\n inbox: inbox,\n };\n};\n"],"names":["reactNodeToHTMLElement","node","container","document","createElement","flushSync","root","createRoot","render","CourierClientComponent","children","isMounted","setIsMounted","useState","useEffect","window","props","inboxRef","useRef","inbox","current","onMessageClick","onMessageActionClick","onMessageLongPress","renderHeader","queueMicrotask","setHeader","headerProps","renderListItem","setListItem","itemProps","renderEmptyState","setEmptyState","emptyStateProps","renderLoadingState","setLoadingState","loadingStateProps","renderErrorState","setErrorState","errorStateProps","renderPaginationItem","setPaginationItem","paginationProps","setFeedType","feedType","jsxRuntime","jsx","ref","height","lightTheme","JSON","stringify","darkTheme","mode","menuRef","menu","renderPopupHeader","setPopupHeader","renderPopupListItem","setPopupListItem","renderPopupEmptyState","setPopupEmptyState","renderPopupLoadingState","setPopupLoadingState","renderPopupErrorState","setPopupErrorState","renderPopupPaginationItem","setPopupPaginationItem","renderPopupMenuButton","setPopupMenuButton","buttonProps","popupAlignment","popupWidth","popupHeight","left","top","right","bottom","signIn","Courier","shared","signOut","loadInbox","CourierInboxDatastore","load","fetchNextPageOfMessages","setPaginationLimit","limit","paginationLimit","readMessage","message","unreadMessage","clickMessage","archiveMessage","openMessage","unarchiveMessage","readAllMessages","auth","setAuth","React","userId","setInbox","listener","addAuthenticationListener","refreshAuth","inboxListener","CourierInboxDataStoreListener","onError","error","refreshInbox","onDataSetChange","onPageAdded","onMessageAdd","onMessageRemove","onMessageUpdate","onUnreadCountChange","addDataStoreListener","remove","options","client","_a","datastore","inboxDataSet","archive","archiveDataSet","unreadCount"],"mappings":"2QAUO,SAASA,EAAuBC,GAC/B,MAAAC,EAAYC,SAASC,cAAc,OAOlC,OAJPC,EAAAA,WAAU,MAaZ,SAAgBJ,EAAiBC,GACzB,MAAAI,EAAOC,aAAWL,GACjBI,EAAKE,OAAOP,EACrB,CAfIO,CAAOP,EAAMC,EAAS,IAGjBA,CACT,CCbO,MAAMO,EAAuD,EAAGC,eACrE,MAAOC,EAAWC,GAAgBC,EAAAA,UAAS,GAOvC,OALJC,EAAAA,WAAU,KACRF,GAAa,EAAI,GAChB,IAGmB,oBAAXG,OACF,KAGJJ,oBAIKD,aAHD,IAGU,uBCCQM,IACrB,MAAAC,EAAWC,SAA4B,MAwG7C,OArGAJ,EAAAA,WAAU,KACR,MAAMK,EAAQF,EAASG,QAClBD,GACCA,EAAAE,eAAeL,EAAMK,eAAc,GACxC,CAACL,EAAM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