capdebug 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -1
- package/android/build/.transforms/105231053f5053e70f17f15178bed793/results.bin +1 -0
- package/android/build/.transforms/7c2b02c40854250ff97be5e9e723091e/results.bin +1 -0
- package/android/build/.transforms/ca1c0f6bb67b5238fd83a40c3a1c0ddd/results.bin +1 -0
- package/android/build/.transforms/ca1c0f6bb67b5238fd83a40c3a1c0ddd/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +9 -0
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output-metadata.json +18 -0
- package/android/build/intermediates/aar_metadata/debug/aar-metadata.properties +6 -0
- package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +1 -0
- package/android/build/intermediates/compile_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/compile_r_class_jar/debug/R.jar +0 -0
- package/android/build/intermediates/compile_symbol_list/debug/R.txt +0 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +1 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +2 -0
- package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +2 -0
- package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +2 -0
- package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +2 -0
- package/android/build/intermediates/java_res/debug/out/META-INF/capdebug_debug.kotlin_module +0 -0
- package/android/build/intermediates/local_only_symbol_list/debug/R-def.txt +2 -0
- package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +11 -0
- package/android/build/intermediates/merged_manifest/debug/AndroidManifest.xml +9 -0
- package/android/build/intermediates/navigation_json/debug/navigation.json +1 -0
- package/android/build/intermediates/runtime_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +1 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab +2 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/local-state/build-history.bin +0 -0
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +20 -0
- package/android/build/tmp/kotlin-classes/debug/META-INF/capdebug_debug.kotlin_module +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/capdebug/plugin/CapDebugPlugin$Companion.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/capdebug/plugin/CapDebugPlugin.class +0 -0
- package/android/src/main/java/com/capdebug/plugin/CapDebugPlugin.kt +54 -0
- package/bin/capdebug.js +8 -0
- package/dist/capacitor/deep-link.d.ts +4 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/qr.d.ts +15 -0
- package/dist/cli/server.d.ts +34 -0
- package/dist/cli.js +1868 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/plugin.cjs.js +2639 -1912
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +2749 -2022
- package/dist/plugin.js.map +1 -1
- package/dist/plugin.mjs +2632 -1913
- package/dist/plugin.mjs.map +1 -1
- package/dist/remote/buffer.d.ts +13 -0
- package/dist/remote/desktop-viewer-html.d.ts +10 -0
- package/dist/remote/pairing-page-html.d.ts +8 -0
- package/dist/remote/pairing.d.ts +34 -0
- package/dist/remote/protocol.d.ts +14 -0
- package/dist/remote/remote-manager.d.ts +19 -0
- package/dist/remote/signaling.d.ts +27 -0
- package/dist/remote/transport.d.ts +15 -0
- package/dist/remote/types.d.ts +69 -0
- package/dist/remote/webrtc-transport.d.ts +47 -0
- package/ios/Sources/CapDebugPlugin/CapDebugPlugin.swift +41 -0
- package/package.json +6 -2
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CapDebugEvent } from '../types';
|
|
2
|
+
export declare class RemoteEventBuffer {
|
|
3
|
+
private buffer;
|
|
4
|
+
private maxCapacity;
|
|
5
|
+
private droppedCount;
|
|
6
|
+
constructor(maxCapacity?: number);
|
|
7
|
+
push(event: CapDebugEvent): void;
|
|
8
|
+
flush(): CapDebugEvent[];
|
|
9
|
+
clear(): void;
|
|
10
|
+
size(): number;
|
|
11
|
+
getDroppedCount(): number;
|
|
12
|
+
incrementDropped(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTML template for the Desktop Remote Viewer (http://localhost:4783).
|
|
3
|
+
* Contains full client-side WebRTC host logic, real-time log stream UI,
|
|
4
|
+
* filtering, JSON inspection, and remote controls.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getDesktopViewerHtml(options: {
|
|
7
|
+
sessionId: string;
|
|
8
|
+
secret: string;
|
|
9
|
+
signalingUrl: string;
|
|
10
|
+
}): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { PairingSession } from './types';
|
|
2
|
+
export interface ParsedPairingInfo {
|
|
3
|
+
sessionId: string;
|
|
4
|
+
secret: string;
|
|
5
|
+
signalingUrl?: string;
|
|
6
|
+
rawUrl: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class PairingHelper {
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new pairing session with given TTL (default 5 minutes).
|
|
11
|
+
*/
|
|
12
|
+
static createSession(ttlMs?: number): PairingSession;
|
|
13
|
+
/**
|
|
14
|
+
* Generates a short, human-readable session ID (e.g. "K7P4-M2" or "7HQ2-9X").
|
|
15
|
+
*/
|
|
16
|
+
static generateSessionId(): string;
|
|
17
|
+
/**
|
|
18
|
+
* Generates a cryptographically strong 128-bit random secret string.
|
|
19
|
+
*/
|
|
20
|
+
static generateSecret(): string;
|
|
21
|
+
/**
|
|
22
|
+
* Formats a web pairing URL where the secret is stored strictly in the URL fragment (#SECRET).
|
|
23
|
+
*/
|
|
24
|
+
static formatPairingUrl(baseUrl: string, sessionId: string, secret: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Formats a Capacitor mobile deep link URL.
|
|
27
|
+
*/
|
|
28
|
+
static formatDeepLinkUrl(sessionId: string, secret: string, signalingUrl?: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Parses a web pairing URL or Capacitor deep-link URL into session and secret components.
|
|
31
|
+
*/
|
|
32
|
+
static parseUrl(urlStr: string): ParsedPairingInfo | null;
|
|
33
|
+
private static getRandomBytes;
|
|
34
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CapDebugEvent } from '../types';
|
|
2
|
+
import type { ControlCommand, RemoteMessage } from './types';
|
|
3
|
+
export declare const PROTOCOL_VERSION = 1;
|
|
4
|
+
export declare class RemoteProtocol {
|
|
5
|
+
static createHello(capdebugVersion?: string, platform?: string, deviceName?: string): RemoteMessage;
|
|
6
|
+
static createHelloAck(): RemoteMessage;
|
|
7
|
+
static createEvent(event: CapDebugEvent): RemoteMessage;
|
|
8
|
+
static createBatch(events: CapDebugEvent[]): RemoteMessage;
|
|
9
|
+
static createControl(command: ControlCommand): RemoteMessage;
|
|
10
|
+
static createPing(timestamp?: number): RemoteMessage;
|
|
11
|
+
static createPong(pingTimestamp: number): RemoteMessage;
|
|
12
|
+
static serialize(message: RemoteMessage): string;
|
|
13
|
+
static parse(raw: string): RemoteMessage | null;
|
|
14
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CapDebugStore } from '../store';
|
|
2
|
+
import type { ConnectionDiagnostics, PairingConfig, TransportStatus } from './types';
|
|
3
|
+
import { WebRTCTransport } from './webrtc-transport';
|
|
4
|
+
export declare class RemoteManager {
|
|
5
|
+
private transport;
|
|
6
|
+
private store;
|
|
7
|
+
private isListening;
|
|
8
|
+
private eventListener;
|
|
9
|
+
constructor(store: CapDebugStore);
|
|
10
|
+
get activeTransport(): WebRTCTransport;
|
|
11
|
+
connect(config: PairingConfig): Promise<void>;
|
|
12
|
+
disconnect(): void;
|
|
13
|
+
status(): TransportStatus;
|
|
14
|
+
getDiagnostics(): ConnectionDiagnostics;
|
|
15
|
+
handlePairingUrl(url: string): Promise<boolean>;
|
|
16
|
+
private startEventListener;
|
|
17
|
+
private stopEventListener;
|
|
18
|
+
private setupControlHandler;
|
|
19
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { PairingSessionInfo, SignalingMessage } from './types';
|
|
2
|
+
export interface SignalingTransport {
|
|
3
|
+
createSession(ttlSeconds?: number): Promise<PairingSessionInfo>;
|
|
4
|
+
joinSession(sessionId: string, secret: string): Promise<void>;
|
|
5
|
+
send(message: SignalingMessage): Promise<void>;
|
|
6
|
+
onMessage(callback: (message: SignalingMessage) => void): () => void;
|
|
7
|
+
close(): void;
|
|
8
|
+
}
|
|
9
|
+
export declare class HttpSseSignalingClient implements SignalingTransport {
|
|
10
|
+
private baseUrl;
|
|
11
|
+
private sessionId;
|
|
12
|
+
private secret;
|
|
13
|
+
private role;
|
|
14
|
+
private eventSource;
|
|
15
|
+
private listeners;
|
|
16
|
+
private isClosed;
|
|
17
|
+
private pollTimer;
|
|
18
|
+
constructor(baseUrl: string);
|
|
19
|
+
createSession(ttlSeconds?: number): Promise<PairingSessionInfo>;
|
|
20
|
+
joinSession(sessionId: string, secret: string): Promise<void>;
|
|
21
|
+
send(message: SignalingMessage): Promise<void>;
|
|
22
|
+
onMessage(callback: (message: SignalingMessage) => void): () => void;
|
|
23
|
+
close(): void;
|
|
24
|
+
private connectEventStream;
|
|
25
|
+
private startPolling;
|
|
26
|
+
private dispatchMessage;
|
|
27
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CapDebugEvent } from '../types';
|
|
2
|
+
import type { ConnectionDiagnostics, ControlCommand, PairingConfig, TransportStatus } from './types';
|
|
3
|
+
export interface CapDebugTransport {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
connect(config: PairingConfig): Promise<void>;
|
|
6
|
+
send(event: CapDebugEvent): void;
|
|
7
|
+
sendControl(command: ControlCommand): void;
|
|
8
|
+
disconnect(): void;
|
|
9
|
+
getStatus(): TransportStatus;
|
|
10
|
+
getDiagnostics(): ConnectionDiagnostics;
|
|
11
|
+
onEvent(callback: (event: CapDebugEvent) => void): () => void;
|
|
12
|
+
onControl(callback: (command: ControlCommand) => void): () => void;
|
|
13
|
+
onStatusChange(callback: (status: TransportStatus) => void): () => void;
|
|
14
|
+
onDiagnostics(callback: (diag: ConnectionDiagnostics) => void): () => void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { CapDebugEvent } from '../types';
|
|
2
|
+
export type SessionStatus = 'waiting' | 'peer-joined' | 'negotiating' | 'connected' | 'expired' | 'closed';
|
|
3
|
+
export interface PairingSession {
|
|
4
|
+
id: string;
|
|
5
|
+
createdAt: number;
|
|
6
|
+
expiresAt: number;
|
|
7
|
+
status: SessionStatus;
|
|
8
|
+
}
|
|
9
|
+
export interface PairingSessionInfo {
|
|
10
|
+
sessionId: string;
|
|
11
|
+
secret: string;
|
|
12
|
+
createdAt: number;
|
|
13
|
+
expiresAt: number;
|
|
14
|
+
signalingUrl: string;
|
|
15
|
+
pairingUrl: string;
|
|
16
|
+
deepLinkUrl: string;
|
|
17
|
+
}
|
|
18
|
+
export interface PairingConfig {
|
|
19
|
+
sessionId: string;
|
|
20
|
+
secret: string;
|
|
21
|
+
signalingUrl?: string;
|
|
22
|
+
iceServers?: RTCIceServer[];
|
|
23
|
+
isHost?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export type SignalingMessageType = 'join' | 'peer-joined' | 'offer' | 'answer' | 'ice-candidate' | 'disconnect' | 'error';
|
|
26
|
+
export interface SignalingMessage {
|
|
27
|
+
sessionId: string;
|
|
28
|
+
secret: string;
|
|
29
|
+
type: SignalingMessageType;
|
|
30
|
+
sender: 'host' | 'peer';
|
|
31
|
+
payload?: any;
|
|
32
|
+
timestamp?: number;
|
|
33
|
+
}
|
|
34
|
+
export type TransportStatus = 'disconnected' | 'connecting' | 'signaling' | 'connected' | 'reconnecting' | 'failed';
|
|
35
|
+
export interface ConnectionDiagnostics {
|
|
36
|
+
transport: 'webrtc' | 'local' | 'mock';
|
|
37
|
+
status: TransportStatus;
|
|
38
|
+
iceConnectionState?: string;
|
|
39
|
+
iceGatheringState?: string;
|
|
40
|
+
signalingState?: string;
|
|
41
|
+
connectionState?: string;
|
|
42
|
+
candidateType?: string;
|
|
43
|
+
protocol?: string;
|
|
44
|
+
route?: 'direct / LAN' | 'STUN / WAN' | 'relay / TURN' | 'unknown';
|
|
45
|
+
rttMs?: number;
|
|
46
|
+
bufferedAmountBytes?: number;
|
|
47
|
+
droppedEventsCount?: number;
|
|
48
|
+
totalEventsSent?: number;
|
|
49
|
+
totalEventsReceived?: number;
|
|
50
|
+
connectedAt?: number;
|
|
51
|
+
deviceName?: string;
|
|
52
|
+
platform?: string;
|
|
53
|
+
}
|
|
54
|
+
export type ControlCommandType = 'pause' | 'resume' | 'clear' | 'snapshot.request' | 'collector.enable' | 'collector.disable' | 'ping' | 'pong' | 'disconnect';
|
|
55
|
+
export interface ControlCommand {
|
|
56
|
+
type: ControlCommandType;
|
|
57
|
+
collector?: string;
|
|
58
|
+
timestamp?: number;
|
|
59
|
+
payload?: unknown;
|
|
60
|
+
}
|
|
61
|
+
export interface RemoteMessage {
|
|
62
|
+
v: 1;
|
|
63
|
+
type: 'hello' | 'hello-ack' | 'event' | 'events-batch' | 'control' | 'ping' | 'pong';
|
|
64
|
+
payload?: unknown;
|
|
65
|
+
event?: CapDebugEvent;
|
|
66
|
+
events?: CapDebugEvent[];
|
|
67
|
+
command?: ControlCommand;
|
|
68
|
+
timestamp?: number;
|
|
69
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { CapDebugEvent } from '../types';
|
|
2
|
+
import type { CapDebugTransport } from './transport';
|
|
3
|
+
import type { ConnectionDiagnostics, ControlCommand, PairingConfig, TransportStatus } from './types';
|
|
4
|
+
export declare class WebRTCTransport implements CapDebugTransport {
|
|
5
|
+
readonly id = "webrtc";
|
|
6
|
+
private pc;
|
|
7
|
+
private signaling;
|
|
8
|
+
private config;
|
|
9
|
+
private eventsChannel;
|
|
10
|
+
private controlChannel;
|
|
11
|
+
private status;
|
|
12
|
+
private buffer;
|
|
13
|
+
private eventListeners;
|
|
14
|
+
private controlListeners;
|
|
15
|
+
private statusListeners;
|
|
16
|
+
private diagnosticsListeners;
|
|
17
|
+
private pingTimer;
|
|
18
|
+
private statsTimer;
|
|
19
|
+
private rttMs;
|
|
20
|
+
private totalEventsSent;
|
|
21
|
+
private totalEventsReceived;
|
|
22
|
+
private connectedAt;
|
|
23
|
+
private remoteDeviceName;
|
|
24
|
+
private remotePlatform;
|
|
25
|
+
private diagnostics;
|
|
26
|
+
connect(config: PairingConfig): Promise<void>;
|
|
27
|
+
send(event: CapDebugEvent): void;
|
|
28
|
+
sendControl(command: ControlCommand): void;
|
|
29
|
+
disconnect(): void;
|
|
30
|
+
getStatus(): TransportStatus;
|
|
31
|
+
getDiagnostics(): ConnectionDiagnostics;
|
|
32
|
+
onEvent(callback: (event: CapDebugEvent) => void): () => void;
|
|
33
|
+
onControl(callback: (command: ControlCommand) => void): () => void;
|
|
34
|
+
onStatusChange(callback: (status: TransportStatus) => void): () => void;
|
|
35
|
+
onDiagnostics(callback: (diag: ConnectionDiagnostics) => void): () => void;
|
|
36
|
+
private handleSignalingMessage;
|
|
37
|
+
private initPeerConnection;
|
|
38
|
+
private startHandshakeAsInitiator;
|
|
39
|
+
private handleOffer;
|
|
40
|
+
private setupDataChannel;
|
|
41
|
+
private handleControlMessage;
|
|
42
|
+
private startTimers;
|
|
43
|
+
private stopTimers;
|
|
44
|
+
private queryWebRTCStats;
|
|
45
|
+
private setStatus;
|
|
46
|
+
private updateDiagnostics;
|
|
47
|
+
}
|
|
@@ -20,14 +20,55 @@ public class CapDebugPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
20
20
|
private let monitorQueue = DispatchQueue(label: "com.capdebug.networkMonitor")
|
|
21
21
|
private var lastKnownPath: NWPath?
|
|
22
22
|
|
|
23
|
+
private static weak var activeBridge: CAPBridgeProtocol?
|
|
24
|
+
|
|
23
25
|
override public func load() {
|
|
24
26
|
super.load()
|
|
27
|
+
Self.activeBridge = self.bridge
|
|
25
28
|
networkMonitor.pathUpdateHandler = { [weak self] path in
|
|
26
29
|
self?.lastKnownPath = path
|
|
27
30
|
}
|
|
28
31
|
networkMonitor.start(queue: monitorQueue)
|
|
29
32
|
}
|
|
30
33
|
|
|
34
|
+
/// Emits a telemetry or debug event directly from Swift native code into CapDebug.
|
|
35
|
+
@objc public static func emit(
|
|
36
|
+
type: String,
|
|
37
|
+
message: String? = nil,
|
|
38
|
+
data: [String: Any]? = nil,
|
|
39
|
+
level: String = "info",
|
|
40
|
+
duration: Double = -1,
|
|
41
|
+
source: String = "native",
|
|
42
|
+
bridge: CAPBridgeProtocol? = nil
|
|
43
|
+
) {
|
|
44
|
+
#if !DEBUG
|
|
45
|
+
// Zero-overhead guard: No-op in release/production builds
|
|
46
|
+
return
|
|
47
|
+
#else
|
|
48
|
+
guard let targetBridge = bridge ?? activeBridge else { return }
|
|
49
|
+
|
|
50
|
+
var payload: [String: Any] = [
|
|
51
|
+
"source": source,
|
|
52
|
+
"platform": "ios",
|
|
53
|
+
"type": type,
|
|
54
|
+
"level": level,
|
|
55
|
+
"timestamp": Int64(Date().timeIntervalSince1970 * 1000)
|
|
56
|
+
]
|
|
57
|
+
if let message = message { payload["message"] = message }
|
|
58
|
+
if let data = data { payload["data"] = data }
|
|
59
|
+
if duration >= 0 { payload["duration"] = duration }
|
|
60
|
+
|
|
61
|
+
guard let jsonData = try? JSONSerialization.data(withJSONObject: payload, options: []),
|
|
62
|
+
let jsonString = String(data: jsonData, encoding: .utf8) else { return }
|
|
63
|
+
|
|
64
|
+
let js = "window.dispatchEvent(new CustomEvent('capdebug', { detail: \(jsonString) }));"
|
|
65
|
+
|
|
66
|
+
DispatchQueue.main.async {
|
|
67
|
+
targetBridge.webView?.evaluateJavaScript(js, completionHandler: nil)
|
|
68
|
+
}
|
|
69
|
+
#endif
|
|
70
|
+
}
|
|
71
|
+
|
|
31
72
|
deinit {
|
|
32
73
|
networkMonitor.cancel()
|
|
33
74
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "capdebug",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Lightweight, embedded debug viewer and diagnostics plugin for Capacitor apps",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/plugin.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"unpkg": "dist/plugin.js",
|
|
9
|
+
"bin": {
|
|
10
|
+
"capdebug": "./bin/capdebug.js"
|
|
11
|
+
},
|
|
9
12
|
"files": [
|
|
10
13
|
"dist/",
|
|
14
|
+
"bin/",
|
|
11
15
|
"ios/",
|
|
12
16
|
"android/",
|
|
13
17
|
"CapDebug.podspec"
|
|
@@ -41,10 +45,10 @@
|
|
|
41
45
|
"devDependencies": {
|
|
42
46
|
"@capacitor/core": "^6.2.0",
|
|
43
47
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
44
|
-
"@rollup/plugin-typescript": "^11.1.6",
|
|
45
48
|
"@types/node": "^22.10.2",
|
|
46
49
|
"jsdom": "^25.0.1",
|
|
47
50
|
"rollup": "^4.28.1",
|
|
51
|
+
"rollup-plugin-esbuild": "^6.2.1",
|
|
48
52
|
"tslib": "^2.8.1",
|
|
49
53
|
"typescript": "^5.7.2",
|
|
50
54
|
"vitest": "^2.1.8"
|