Démarrage
Copiez un prompt de configuration avec les étapes d'installation et la guide Markdown complet pour ce plugin.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-webview-guardian`
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/webview-guardian/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.
Installation
Sous-titre « Installation »Vous pouvez utiliser notre configuration assistée par l'IA pour installer le plugin. Ajoutez les Capgo compétences à votre outil IA à l'aide de la commande suivante :
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsEnsuite, utilisez la prompt suivante :
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-webview-guardian` plugin in my project.Si vous préférez la configuration manuelle, installez le plugin en exécutant les commandes suivantes et suivez les instructions spécifiques à la plateforme ci-dessous :
bun add @capgo/capacitor-webview-guardianbunx cap syncImporter
Section intitulée « Importer »import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';API Vue d'ensemble
Section intitulée « API Vue d'ensemble »startMonitoring
Section intitulée « startMonitoring »Démarre l'observation des événements de premier plan et vérifie automatiquement la santé de la vue Web.
import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';
await WebviewGuardian.startMonitoring();stopMonitoring
Section intitulée “stopMonitoring”Arrête tout monitoring automatique en avant-plan.
import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';
await WebviewGuardian.stopMonitoring();getState
Section intitulée “getState”Renvoie l'état de monitoring le plus récent connu.
import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';
await WebviewGuardian.getState();checkNow
Section intitulée “checkNow”Force un sondage de santé WebView immédiatement.
import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';
await WebviewGuardian.checkNow();Référence de type
Section intitulée “Référence de type”StartMonitoringOptions
Section intitulée “StartMonitoringOptions”export interface StartMonitoringOptions { /** * Delay (in ms) before running a health check after the app re-enters the foreground. * Defaults to 600ms to let the bridge finish resuming. */ foregroundDebounceMs?: number;
/** * Script executed via `evaluateJavascript`/`evaluateJavaScript` to confirm the WebView is alive. * Defaults to `document.readyState`. */ pingScript?: string;
/** * Automatically reloads the WebView when a terminated render process is detected. * Disable to receive `webviewCrashed` events and restart manually. */ autoRestart?: boolean;
/** * Strategy used when restarting the WebView. Defaults to `reload`. */ restartStrategy?: RestartStrategy;
/** * Custom HTTPS/HTTP URL to load when `restartStrategy` is `customUrl`. */ customRestartUrl?: string;
/** * Emits verbose logging in the native layer when true. */ debug?: boolean;
/** * Whether an immediate health check should be executed right after enabling monitoring. * Defaults to `true`. */ runInitialCheck?: boolean;}GuardianState
Section intitulée « État du gardien »export interface GuardianState { monitoring: boolean; reason: string; timestamp: string; lastHealthyAt?: string; lastRestartAt?: string; lastCrashAt?: string; pendingRestartReason?: string; error?: string;}CheckNowOptions
Section intitulée « Options de vérification maintenant »export interface CheckNowOptions { /** * Text tag describing why a manual check is being requested. */ reason?: string;}export interface CheckResult { healthy: boolean; restarted: boolean; reason: string; timestamp: string; error?: string; pendingRestart?: boolean;}GuardianEvent
Section intitulée « Événement du gardien »export type GuardianEvent = GuardianState;RestartStrategy
Section intitulée « Stratégie de redémarrage »export type RestartStrategy = 'reload' | 'reloadFromOrigin' | 'customUrl';Source de vérité
Section intitulée « Source De Vérité »Cette page est générée à partir du plugin’s src/definitions.ts. Re-run la synchronisation lorsque les informations publiques API changent en amont.
Continuez de là depuis Getting Started
Section intitulée « Continuez de là depuis Getting Started »Si vous utilisez Getting Started pour planifier le comportement des médias et de l'interface natifs, connectez-l’avec Utilisez @__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-webview-guardian pour la capacité native dans Utilisez @capgo/capacitor-webview-guardian, Utilisez @capgo/capacitor-live-activities pour la capacité native dans Utilisez @capgo/capacitor-live-activities, Utilisez @capgo/capacitor-live-activities pour la capacité native dans Utilisez @capgo/capacitor-live-activities, @capgo/capacitor-activités en direct pour les détails d'implémentation dans @capgo/capacitor-activités en direct, En utilisant @capgo/capacitor-joueur de vidéo pour la capacité native dans En utilisant @capgo/capacitor-joueur de vidéo, et @capgo/capacitor-joueur de vidéo pour les détails d'implémentation dans @capgo/capacitor-joueur de vidéo.