Zum Inhalt springen

Einstieg

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

Speichern Sie die Einstellungen für den Remote-Entwicklungs-Server, die für zukünftige Verbindungen verwendet werden.

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

Wenn keine aktive WebSocket-Verbindung besteht, eine neue herstellen.

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

Schließen Sie die aktuelle WebSocket-Verbindung und deaktivieren Sie die automatische Wiederherstellung.

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

Gibt den aktuellen Verbindungszustand zurück.

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

Ein vollständiges Neuladen des Capacitor WebView auslösen.

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

Wenn die Laufzeit unterstützt, ein einzelnes Datei/Modul neu laden (fällt zurück auf Vollneuladen).

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

Diese Seite wird aus dem Plugin generiert. src/definitions.ts. Re-run the Sync, wenn die öffentliche API upstream geändert wird.

Wenn Sie " Getting Started um das Dashboard und API-Operationen zu planen, verbinden Sie es mit Using @capgo/capacitor-live-reload für die native Fähigkeit in Using @capgo/capacitor-live-reload API Übersicht für die Implementierungsdetails in API Übersicht Einführung für die Implementierungsdetails in Einführung API Schlüssel für die Implementierungsdetails in API Schlüssel und Geräte für die Implementierungsdetails in Geräte.