はじめに
インストール手順とこのプラグインの完全なマークダウンガイドを含む設定用の質問をコピーする
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-live-reload`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/live-reload/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
インストール
「インストール」のセクションbun add @capgo/capacitor-live-reloadbunx cap syncインポート
「インポート」のセクションimport { LiveReload } from '@capgo/capacitor-live-reload';API オーバービュー
「API オーバービュー」タイトルのセクションconfigureServer
「configureServer」タイトルのセクション接続先の開発サーバーの設定を保存して、次回の接続に使用します。
import { LiveReload } from '@capgo/capacitor-live-reload';
await LiveReload.configureServer({} as ConfigureServerOptions);connect
「接続」タイトルのセクション既存の WebSocket 接続が存在しない場合、WebSocket 接続を確立します。
import { LiveReload } from '@capgo/capacitor-live-reload';
await LiveReload.connect();disconnect
「切断」タイトルのセクション現在の WebSocket 接続を閉じて、自動再接続を無効にします。
import { LiveReload } from '@capgo/capacitor-live-reload';
await LiveReload.disconnect();getStatus
ステータスを取得現在の接続状態を取得します。
import { LiveReload } from '@capgo/capacitor-live-reload';
await LiveReload.getStatus();reload
リロードフルリロードをトリガーし、Capacitor WebViewを更新します。
import { LiveReload } from '@capgo/capacitor-live-reload';
await LiveReload.reload();reloadFile
リロード単一のファイル/モジュールをリロードします (サポートされている場合、フルリロードにフォールバックします)。
import { LiveReload } from '@capgo/capacitor-live-reload';
await LiveReload.reloadFile({} as FileUpdatePayload);型リファレンス
型リファレンスConfigureServerOptions
サーバーオプションを設定export interface ConfigureServerOptions { /** * Base URL for the dev server (e.g. https://dev.local:5173). * When a connection is established the Capacitor WebView navigates to this URL. */ url: string; /** Optional WebSocket path override when different from /ws. */ websocketPath?: string; /** Extra headers sent when creating the WebSocket connection. */ headers?: Record<string, string>; /** Automatically reconnect when the socket closes unexpectedly. Default: true. */ autoReconnect?: boolean; /** Delay (ms) between reconnection attempts. Default: 2000. */ reconnectInterval?: number;}LiveReloadStatus
LiveReloadStatusのセクションexport interface LiveReloadStatus { connected: boolean; url?: string;}FileUpdatePayload
FileUpdatePayloadのセクションexport interface FileUpdatePayload { path: string; hash?: string;}LiveReloadEventCallback
LiveReloadEventCallbackのセクションexport type LiveReloadEventCallback = (event: LiveReloadEventPayload) => void;LiveReloadStatusCallback
LiveReloadStatusCallbackのセクションexport type LiveReloadStatusCallback = (status: LiveReloadStatus) => void;LiveReloadEventPayload
LiveReloadEventPayloadのセクションexport interface LiveReloadEventPayload { type: LiveReloadMessageType; /** Populated when type === 'file-update'. */ file?: FileUpdatePayload; /** Optional human-readable message for errors or status changes. */ message?: string;}LiveReloadMessageType
LiveReloadMessageTypeのセクションexport type LiveReloadMessageType = 'full-reload' | 'file-update' | 'error' | 'connected' | 'disconnected';真実の源
「真実の源」というセクションこのページはプラグインから生成されています。 src/definitions.tsパブリック API がアップストリームで変更されたら、再度同期を実行してください。