Passer à la navigation

Démarrage

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

Stockez les paramètres du serveur de développement distant utilisés pour les connexions ultérieures.

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

Établissez une connexion WebSocket si une connexion n'est pas déjà active.

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

Fermez la connexion WebSocket actuelle et désactivez la reconnexion automatique.

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

Renvoie le statut de connexion actuel.

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

Déclenchez un rechargement complet de la Capacitor Vue Web.

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

Rechargez un seul fichier/module si le runtime le supporte (retourne à un rechargement complet).

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

Cette page est générée à partir du plugin’s src/definitions.tsRe-run the sync when the public API changes upstream.