__CAPGO_KEEP_2__

はじめましょう

GitHub

CapgoのAI-Assistedセットアップを使用してプラグインをインストールできます。次のコマンドを使用して、CapgoスキルをAIツールに追加してください。

コピー
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

context

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-webview-guardian` plugin in my project.

Manual Setup を選択している場合、以下のコマンドを実行し、下記のプラットフォーム固有の手順に従ってプラグインをインストールしてください。

ターミナルウィンドウ
bun add @capgo/capacitor-webview-guardian
bunx cap sync

インポート

インポート
import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';

API の概要

API の概要

__CAPGO_KEEP_0__ の監視開始

import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';
const result = await WebviewGuardian.startMonitoring();
console.log(result);

自動前景監視を停止します。

import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';
const result = await WebviewGuardian.stopMonitoring();
console.log(result);

getState

import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';
const result = await WebviewGuardian.getState();
console.log(result);

checkNow

import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';
const result = await WebviewGuardian.checkNow();
console.log(result);

ウェブビューの健康プローブを即時実行します。

型参照

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;
}
export interface GuardianState {
monitoring: boolean;
reason: string;
timestamp: string;
lastHealthyAt?: string;
lastRestartAt?: string;
lastCrashAt?: string;
pendingRestartReason?: string;
error?: string;
}
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;
export type RestartStrategy = 'reload' | 'reloadFromOrigin' | 'customUrl';

このページはプラグインから生成されます。 src/definitions.ts. 再度、パブリック API がアップストリームで変更されたときは、再度同期を実行してください。

Getting Started から続けてください。

Section titled “Getting Started から続けてください。”

Capacitor を使用している場合 Getting Started Capacitor を使用してネイティブメディアとインターフェイスの動作を計画する場合、Capacitor を使用してネイティブ機能と接続してください。 Using @capgo/capacitor-webview-guardian Using @capgo/capacitor-webview-guardian @capgo/capacitorライブアクティビティを使用 Using @capgo/capacitor-live-activities @capgo/capacitor-ライブアクティビティ @capgo/capacitor-live-activities @capgo/capacitor-ビデオプレーヤー Using @capgo/capacitor-video-player, and @capgo/capacitor-video-player @capgo/capacitor-video-playerの実装詳細のために。