Inizia
Copia un prompt di configurazione con i passaggi di installazione e la guida markdown completa per questo plugin.
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.
Installa
Sezione intitolata “Installa”bun add @capgo/capacitor-live-reloadbunx cap syncImporta
Sezione intitolata “Importa”import { LiveReload } from '@capgo/capacitor-live-reload';API Panoramica
Sezione intitolata “API Panoramica”configureServer
Sezione intitolata “configuraServer”Salva le impostazioni del server di sviluppo remoto utilizzate per le connessioni successive.
import { LiveReload } from '@capgo/capacitor-live-reload';
await LiveReload.configureServer({} as ConfigureServerOptions);Stabilisci una connessione WebSocket se non è già attiva.
import { LiveReload } from '@capgo/capacitor-live-reload';
await LiveReload.connect();disconnect
Sezione intitolata “disconnetti”Chiudi la connessione WebSocket corrente e disabilita il riavvio automatico.
import { LiveReload } from '@capgo/capacitor-live-reload';
await LiveReload.disconnect();getStatus
Sezione intitolata “getStatus”Restituisce lo stato di connessione corrente.
import { LiveReload } from '@capgo/capacitor-live-reload';
await LiveReload.getStatus();Attiva un reload completo del WebView Capacitor.
import { LiveReload } from '@capgo/capacitor-live-reload';
await LiveReload.reload();reloadFile
Sezione intitolata “reloadFile”Carica nuovamente un singolo file/modulo se il runtime lo supporta (ricade su reload completo).
import { LiveReload } from '@capgo/capacitor-live-reload';
await LiveReload.reloadFile({} as FileUpdatePayload);Riferimento di tipo
Sezione intitolata “Riferimento di tipo”ConfigureServerOptions
Sezione intitolata “Configura opzioni del server”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
Sezione intitolata “LiveReloadStatus”export interface LiveReloadStatus { connected: boolean; url?: string;}FileUpdatePayload
Sezione intitolata “FileUpdatePayload”export interface FileUpdatePayload { path: string; hash?: string;}LiveReloadEventCallback
Sezione intitolata “LiveReloadEventCallback”export type LiveReloadEventCallback = (event: LiveReloadEventPayload) => void;LiveReloadStatusCallback
Sezione intitolata “LiveReloadStatusCallback”export type LiveReloadStatusCallback = (status: LiveReloadStatus) => void;LiveReloadEventPayload
Sezione intitolata “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
Sezione intitolata “LiveReloadMessageType”export type LiveReloadMessageType = 'full-reload' | 'file-update' | 'error' | 'connected' | 'disconnected';Fonte di Verità
Sezione intitolata “Fonte di Verità”Questa pagina è generata dal plugin’s src/definitions.tsRiepiloga quando le modifiche pubbliche API sono state apportate in fase di sincronizzazione.