컨텐츠로 바로가기

시작하기

설치

설치
터미널 창
bun add @capgo/capacitor-webview-guardian
bunx cap sync
import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';

클립보드 복사

import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';
await WebviewGuardian.startMonitoring();

stopMonitoring

클립보드 복사

Foreground 이벤트 관찰을 중지합니다.

import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';
await WebviewGuardian.stopMonitoring();

getState

getState

최신 모니터링 상태를 반환합니다.

import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';
await WebviewGuardian.getState();

checkNow

checkNow

웹뷰의 즉각적인 건강 검사를 강제합니다.

import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';
await WebviewGuardian.checkNow();

Type Reference

타입 참조

StartMonitoringOptions

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

GuardianState
export interface GuardianState {
monitoring: boolean;
reason: string;
timestamp: string;
lastHealthyAt?: string;
lastRestartAt?: string;
lastCrashAt?: string;
pendingRestartReason?: string;
error?: string;
}

CheckNowOptions

CheckNowOptions 섹션
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;
}
export type GuardianEvent = GuardianState;

RestartStrategy

RestartStrategy 섹션
export type RestartStrategy = 'reload' | 'reloadFromOrigin' | 'customUrl';

이 페이지는 플러그인의 src/definitions.ts공개 API이 업스트림에서 변경될 때 다시 싱크를 실행하세요.