Saltar al contenido

Empezar

Ventana de terminal
bun add @capgo/capacitor-live-reload
bunx cap sync
import { LiveReload } from '@capgo/capacitor-live-reload';

Almacena la configuración del servidor de desarrollo remoto para conexiones subsiguientes.

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

Establish a WebSocket connection if one is not already active.

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

Sección titulada “desconectar”

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

Devuelve el estado de conexión actual.

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

Activar un recarga completa del WebView Capacitor.

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

Recargar un archivo/módulo individual si el entorno de ejecución lo admite (cae en recarga completa).

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';

Esta página se genera a partir del plugin’s src/definitions.tsRe-ejecutar la sincronización cuando el público API cambie en la fuente.