{"version":3,"file":"next.mjs","names":[],"sources":["../src/next.tsx"],"sourcesContent":["\"use client\";\n\nimport { useRouter } from \"next/navigation\";\nimport { useCallback } from \"react\";\nimport {\n  type UseNotionRevalidateOptions,\n  useRevalidateEffect,\n} from \"./internal/revalidate.js\";\n\nexport type {\n  NotionPollOptions,\n  NotionRealtimeOptions,\n  NotionRevalidateTrigger,\n  UseNotionRevalidateOptions,\n} from \"./internal/revalidate.js\";\n\n/**\n * Next.js App Router で SWR 再検証を `router.refresh()` 経由で発火させるフック。\n * RSC ストリームを差分で受け取るため、URL も変わらず別 API fetch も発生しない。\n *\n * @example\n *   useNotionRevalidate({ on: [\"mount\", \"visibility\"] });\n */\nexport function useNotionRevalidate(\n  opts: UseNotionRevalidateOptions = {},\n): void {\n  const router = useRouter();\n  const stable = useCallback(() => {\n    router.refresh();\n  }, [router]);\n  useRevalidateEffect(stable, opts);\n}\n\n/**\n * マウント後に `router.refresh()` を呼び、サーバー側 SWR で差し替わった最新データを\n * 別 fetch なしで取り込むレンダー無しコンポーネント。\n * `poll` を指定すると KV ポーリングで更新完了を検出してから revalidate する。\n */\nexport function NotionRevalidator(props: UseNotionRevalidateOptions): null {\n  useNotionRevalidate(props);\n  return null;\n}\n"],"mappings":";;;;;;;;;;;;AAuBA,SAAgB,oBACd,OAAmC,CAAC,GAC9B;CACN,MAAM,SAAS,UAAU;CAIzB,oBAHe,kBAAkB;EAC/B,OAAO,QAAQ;CACjB,GAAG,CAAC,MAAM,CACe,GAAG,IAAI;AAClC;;;;;;AAOA,SAAgB,kBAAkB,OAAyC;CACzE,oBAAoB,KAAK;CACzB,OAAO;AACT"}