Erste Schritte
Kopiere einen Setup-Prompt mit den Installationsschritten und dem vollständigen Markdown-Guide für dieses 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.
Installieren
Abschnitt „Installation“Du kannst unser KI-gestütztes Setup nutzen, um das Plugin zu installieren. Füge die Capgo Skills mit dem folgenden Befehl deinem KI-Tool hinzu:
bunx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsNutze dann diesen Prompt:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-live-reload` plugin in my project.Wenn du ein manuelles Setup bevorzugst, installiere das Plugin mit den folgenden Befehlen und befolge die plattformspezifischen Anweisungen unten:
bun add @capgo/capacitor-live-reloadbunx cap syncImportieren
Abschnitt mit dem Titel „Import“import { LiveReload } from '@capgo/capacitor-live-reload';Quickstart
Abschnitt „Quick start“import { LiveReload } from '@capgo/capacitor-live-reload';
const result = await LiveReload.configureServer({ url: 'https://example.com' });console.log(result);Beispiel: Verbinden
Abschnitt mit dem Titel „Beispiel: Verbinden“import { LiveReload } from '@capgo/capacitor-live-reload';
const result = await LiveReload.connect();console.log(result);Beispiel: Trennen
Abschnitt mit dem Titel „Beispiel: Trennen“import { LiveReload } from '@capgo/capacitor-live-reload';
const result = await LiveReload.disconnect();console.log(result);Häufige Stolperfallen
Abschnitt „Häufige Fallstricke“- Listener: Handles beim Unmounten von Screens entfernen.
- Nativer Sync: ausführen
bunx cap syncnach Plugin-Upgrades. - Single Source of Truth: Vertrauen
src/definitions.tsim GitHub Repo.
API Übersicht
Abschnitt „API Übersicht“configureServer
Abschnitt mit dem Titel „configureServer“Speichert die Einstellungen des Remote-Dev-Servers für nachfolgende Verbindungen.
import { LiveReload } from '@capgo/capacitor-live-reload';
const result = await LiveReload.configureServer({ url: 'https://example.com' });console.log(result);connect
Abschnitt „connect“Stellt eine WebSocket-Verbindung her, falls keine aktiv ist.
import { LiveReload } from '@capgo/capacitor-live-reload';
const result = await LiveReload.connect();console.log(result);disconnect
Abschnitt „disconnect“Schließt die aktuelle WebSocket-Verbindung und deaktiviert den automatischen Reconnect.
import { LiveReload } from '@capgo/capacitor-live-reload';
const result = await LiveReload.disconnect();console.log(result);getStatus
Abschnitt „getStatus“Gibt den aktuellen Verbindungsstatus zurück.
import { LiveReload } from '@capgo/capacitor-live-reload';
const result = await LiveReload.getStatus();console.log(result);reload
Abschnitt „reload“Löst einen vollständigen Reload der Capacitor WebView aus.
import { LiveReload } from '@capgo/capacitor-live-reload';
await LiveReload.reload();reloadFile
Abschnitt mit dem Titel „reloadFile“Lädt eine einzelne Datei/ein Modul neu, wenn die Runtime das unterstützt (Fallback: vollständiger Reload).
import { LiveReload } from '@capgo/capacitor-live-reload';
await LiveReload.reloadFile({ path: 'path/to/file' });Typreferenz
Abschnitt mit dem Titel „Typreferenz“ConfigureServerOptions
Abschnitt „ConfigureServerOptions“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
Abschnitt „LiveReloadStatus“export interface LiveReloadStatus { connected: boolean; url?: string;}FileUpdatePayload
Abschnitt „FileUpdatePayload“export interface FileUpdatePayload { path: string; hash?: string;}LiveReloadEventCallback
Abschnitt „LiveReloadEventCallback“export type LiveReloadEventCallback = (event: LiveReloadEventPayload) => void;LiveReloadStatusCallback
Abschnitt „LiveReloadStatusCallback“export type LiveReloadStatusCallback = (status: LiveReloadStatus) => void;LiveReloadEventPayload
Abschnitt „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
Abschnitt „LiveReloadMessageType“export type LiveReloadMessageType = 'full-reload' | 'file-update' | 'error' | 'connected' | 'disconnected';Source of Truth
Abschnitt mit dem Titel „Source of Truth“Diese Seite wird aus dem Plugin generiert src/definitions.ts. Führe den Sync erneut aus, wenn sich das öffentliche API upstream ändert.
Weiter geht's nach Getting Started
Abschnitt: „Weiter geht’s mit Getting Started“Wenn du es nutzt Erste Schritte um Dashboard- und API-Operationen zu planen, verbinde es mit @capgo/capacitor-live-reload verwenden für die native Funktion bei der Nutzung von @capgo/capacitor-live-reload, API Übersicht für Details zur Implementierung im API Overview, Einführung für die Implementierungsdetails in der Einleitung, API Schlüssel für das Implementierungsdetail in API Keys und Geräte für das Implementierungsdetail in Devices.