{"version":3,"sources":["../../src/use-activity-mount/index.ts"],"sourcesContent":["import { useMount } from '../use-mount'\n\nimport type { AnyFunc } from '../utils/basic'\n\n/**\n * A React Hook that runs a function only once when the component mounts in an [Activity](https://react.dev/reference/react/Activity) component.\n *\n * Unlike `useMount`, this hook ensures the callback is executed only once **strictly**, even when the Activity\n * is hidden and shown again. This is particularly useful for initialization logic that should only run once\n * in Activity contexts, not every time the component becomes visible.\n *\n * @param callback - The callback function to run when the component is mounted. Can be async.\n * @returns {void} `void`\n *\n * @since 1.13.0\n *\n * @see {@link https://react.dev/reference/react/Activity Activity} - React Activity API\n * @see {@link useMount} - For non-Activity mount behavior\n *\n * @example\n * ```tsx\n * import { Activity } from 'react'\n * import { useActivityMount } from '@shined/react-use'\n *\n * function Sidebar() {\n *   // This callback will only be executed once when the component first mounts,\n *   // NOT when the Activity is shown again after being hidden\n *   useActivityMount(() => {\n *     console.log('Sidebar initialized only once')\n *     fetchUserData()\n *   })\n *\n *   return <div>Sidebar Content</div>\n * }\n *\n * function App() {\n *   const [visible, setVisible] = useState(true)\n *\n *   return (\n *     <Activity mode={visible ? 'visible' : 'hidden'}>\n *       <Sidebar />\n *     </Activity>\n *   )\n * }\n * ```\n */\nexport function useActivityMount(callback?: AnyFunc | null | undefined | false): void {\n  // Use strictOnce=true to ensure the callback only runs once,\n  // even when the Activity component is hidden and shown again\n  useMount(callback, true)\n}\n"],"names":["useActivityMount","callback","useMount"],"mappings":";;;;+BA8CgBA;;;eAAAA;;;wBA9CS;AA8ClB,SAASA,iBAAiBC,QAA6C;IAC5E,6DAA6D;IAC7D,6DAA6D;IAC7DC,IAAAA,kBAAQ,EAACD,UAAU;AACrB"}