Saltare al contenuto

Inizia

Finestra del terminale
bun add @capgo/capacitor-live-reload
bunx cap sync
import { LiveReload } from '@capgo/capacitor-live-reload';

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();

Chiudi la connessione WebSocket corrente e disabilita il riavvio automatico.

import { LiveReload } from '@capgo/capacitor-live-reload';
await LiveReload.disconnect();

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();

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);
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;
}
export interface LiveReloadStatus {
connected: boolean;
url?: string;
}
export interface FileUpdatePayload {
path: string;
hash?: string;
}
export type LiveReloadEventCallback = (event: LiveReloadEventPayload) => void;
export type LiveReloadStatusCallback = (status: LiveReloadStatus) => void;
export interface LiveReloadEventPayload {
type: LiveReloadMessageType;
/** Populated when type === 'file-update'. */
file?: FileUpdatePayload;
/** Optional human-readable message for errors or status changes. */
message?: string;
}
export type LiveReloadMessageType = 'full-reload' | 'file-update' | 'error' | 'connected' | 'disconnected';

Questa pagina è generata dal plugin’s src/definitions.tsRiepiloga quando le modifiche pubbliche API sono state apportate in fase di sincronizzazione.