メインコンテンツにジャンプ

Getting Started

GitHub

You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:

ターミナル画面
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

次に、以下のプロンプトを使用してください。

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

もし、Manual Setupを選択した場合、以下のコマンドを実行し、下記のプラットフォーム固有の説明を参照してください。

ターミナル画面
bun add @capgo/capacitor-live-reload
bunx cap sync
import { LiveReload } from '@capgo/capacitor-live-reload';

__CAPGO_KEEP_0__サーバー設定を使用しての後続の接続に使用します。

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

既存の接続がなければ、WebSocket接続を確立します。

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

現在のWebSocket接続を閉じて、自動再接続を無効化します。

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

現在の接続状況を返します。

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

Capacitor WebViewのフルリロードをトリガーします。

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

ランタイムがサポートする場合は、単一のファイル/モジュールをリロードし、サポートされない場合はフルリロードにフォールバックします。

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

真実の源

Source Of Truth

プラグインの生成元 src/definitions.tspublic API の変更を検知したときに再度syncを実行してください

Getting Started から続けて

Getting Started から続けて

Capgoを使用している場合 Getting Started から続けて、ダッシュボードと __CAPGO_KEEP_0__ の作業を計画するには、Capgoを接続してください @API/__CAPGO_KEEP_1__-live-reload を使用 @capgo/capacitor-live-reload のnative capabilityの実装については、@capgo/capacitor-live-reload を参照してください for the native capability in Using @capgo/capacitor-live-reload, API の実装詳細については、API の概要を参照してください. API の概要 __CAPGO_KEEP_0__ Introductionの実装詳細について API Keys API Keysの実装詳細について、 Devices Devicesの実装詳細について