react-native-debug-toolkit 2.2.0 → 3.0.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 +5 -8
- package/README.zh-CN.md +5 -8
- package/bin/debug-toolkit.js +114 -0
- package/lib/commonjs/features/network/index.js +32 -12
- package/lib/commonjs/features/network/index.js.map +1 -1
- package/lib/commonjs/features/network/networkInterceptor.js +164 -201
- package/lib/commonjs/features/network/networkInterceptor.js.map +1 -1
- package/lib/commonjs/index.js +59 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/ui/panel/DebugPanel.js +25 -0
- package/lib/commonjs/ui/panel/DebugPanel.js.map +1 -1
- package/lib/commonjs/ui/panel/FloatPanelView.js +15 -62
- package/lib/commonjs/ui/panel/FloatPanelView.js.map +1 -1
- package/lib/commonjs/ui/panel/StreamingSettingsModal.js +529 -0
- package/lib/commonjs/ui/panel/StreamingSettingsModal.js.map +1 -0
- package/lib/commonjs/ui/panel/useTabAnimation.js +71 -0
- package/lib/commonjs/ui/panel/useTabAnimation.js.map +1 -0
- package/lib/commonjs/utils/autoDetectDaemon.js +141 -0
- package/lib/commonjs/utils/autoDetectDaemon.js.map +1 -0
- package/lib/commonjs/utils/createPersistedObservableStore.js +23 -3
- package/lib/commonjs/utils/createPersistedObservableStore.js.map +1 -1
- package/lib/commonjs/utils/daemonConnection.js +81 -0
- package/lib/commonjs/utils/daemonConnection.js.map +1 -0
- package/lib/commonjs/utils/daemonSettings.js +110 -0
- package/lib/commonjs/utils/daemonSettings.js.map +1 -0
- package/lib/commonjs/utils/reportToDaemon.js +112 -0
- package/lib/commonjs/utils/reportToDaemon.js.map +1 -0
- package/lib/commonjs/utils/sessionReport.js +132 -0
- package/lib/commonjs/utils/sessionReport.js.map +1 -0
- package/lib/commonjs/utils/streamToDaemon.js +334 -0
- package/lib/commonjs/utils/streamToDaemon.js.map +1 -0
- package/lib/module/features/network/index.js +30 -12
- package/lib/module/features/network/index.js.map +1 -1
- package/lib/module/features/network/networkInterceptor.js +163 -200
- package/lib/module/features/network/networkInterceptor.js.map +1 -1
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/ui/panel/DebugPanel.js +26 -1
- package/lib/module/ui/panel/DebugPanel.js.map +1 -1
- package/lib/module/ui/panel/FloatPanelView.js +16 -63
- package/lib/module/ui/panel/FloatPanelView.js.map +1 -1
- package/lib/module/ui/panel/StreamingSettingsModal.js +524 -0
- package/lib/module/ui/panel/StreamingSettingsModal.js.map +1 -0
- package/lib/module/ui/panel/useTabAnimation.js +67 -0
- package/lib/module/ui/panel/useTabAnimation.js.map +1 -0
- package/lib/module/utils/autoDetectDaemon.js +136 -0
- package/lib/module/utils/autoDetectDaemon.js.map +1 -0
- package/lib/module/utils/createPersistedObservableStore.js +23 -3
- package/lib/module/utils/createPersistedObservableStore.js.map +1 -1
- package/lib/module/utils/daemonConnection.js +77 -0
- package/lib/module/utils/daemonConnection.js.map +1 -0
- package/lib/module/utils/daemonSettings.js +102 -0
- package/lib/module/utils/daemonSettings.js.map +1 -0
- package/lib/module/utils/reportToDaemon.js +105 -0
- package/lib/module/utils/reportToDaemon.js.map +1 -0
- package/lib/module/utils/sessionReport.js +128 -0
- package/lib/module/utils/sessionReport.js.map +1 -0
- package/lib/module/utils/streamToDaemon.js +328 -0
- package/lib/module/utils/streamToDaemon.js.map +1 -0
- package/lib/typescript/src/features/network/index.d.ts +2 -4
- package/lib/typescript/src/features/network/index.d.ts.map +1 -1
- package/lib/typescript/src/features/network/networkInterceptor.d.ts +2 -15
- package/lib/typescript/src/features/network/networkInterceptor.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +11 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/ui/panel/DebugPanel.d.ts.map +1 -1
- package/lib/typescript/src/ui/panel/FloatPanelView.d.ts.map +1 -1
- package/lib/typescript/src/ui/panel/StreamingSettingsModal.d.ts +8 -0
- package/lib/typescript/src/ui/panel/StreamingSettingsModal.d.ts.map +1 -0
- package/lib/typescript/src/ui/panel/useTabAnimation.d.ts +14 -0
- package/lib/typescript/src/ui/panel/useTabAnimation.d.ts.map +1 -0
- package/lib/typescript/src/utils/autoDetectDaemon.d.ts +15 -0
- package/lib/typescript/src/utils/autoDetectDaemon.d.ts.map +1 -0
- package/lib/typescript/src/utils/createPersistedObservableStore.d.ts +2 -1
- package/lib/typescript/src/utils/createPersistedObservableStore.d.ts.map +1 -1
- package/lib/typescript/src/utils/daemonConnection.d.ts +18 -0
- package/lib/typescript/src/utils/daemonConnection.d.ts.map +1 -0
- package/lib/typescript/src/utils/daemonSettings.d.ts +19 -0
- package/lib/typescript/src/utils/daemonSettings.d.ts.map +1 -0
- package/lib/typescript/src/utils/reportToDaemon.d.ts +34 -0
- package/lib/typescript/src/utils/reportToDaemon.d.ts.map +1 -0
- package/lib/typescript/src/utils/sessionReport.d.ts +18 -0
- package/lib/typescript/src/utils/sessionReport.d.ts.map +1 -0
- package/lib/typescript/src/utils/streamToDaemon.d.ts +23 -0
- package/lib/typescript/src/utils/streamToDaemon.d.ts.map +1 -0
- package/node/daemon/src/cli.js +75 -0
- package/node/daemon/src/console/console.html +936 -0
- package/node/daemon/src/console/index.js +47 -0
- package/node/daemon/src/constants.js +32 -0
- package/node/daemon/src/index.js +11 -0
- package/node/daemon/src/server.js +365 -0
- package/node/daemon/src/store.js +110 -0
- package/node/mcp/src/cli.js +31 -0
- package/node/mcp/src/constants.js +13 -0
- package/node/mcp/src/daemonClient.js +132 -0
- package/node/mcp/src/httpClient.js +49 -0
- package/node/mcp/src/index.js +15 -0
- package/node/mcp/src/logs.js +95 -0
- package/node/mcp/src/server.js +144 -0
- package/node/mcp/src/tools.js +84 -0
- package/package.json +10 -5
- package/src/features/network/index.ts +35 -19
- package/src/features/network/networkInterceptor.ts +224 -236
- package/src/index.ts +15 -1
- package/src/ui/panel/DebugPanel.tsx +23 -1
- package/src/ui/panel/FloatPanelView.tsx +10 -68
- package/src/ui/panel/StreamingSettingsModal.tsx +566 -0
- package/src/ui/panel/useTabAnimation.ts +77 -0
- package/src/utils/autoDetectDaemon.ts +175 -0
- package/src/utils/createPersistedObservableStore.ts +16 -3
- package/src/utils/daemonConnection.ts +133 -0
- package/src/utils/daemonSettings.ts +134 -0
- package/src/utils/reportToDaemon.ts +172 -0
- package/src/utils/sessionReport.ts +203 -0
- package/src/utils/streamToDaemon.ts +419 -0
|
@@ -6,8 +6,9 @@ export interface PersistedStoreOptions<T> {
|
|
|
6
6
|
serialize?: (entry: T) => unknown;
|
|
7
7
|
}
|
|
8
8
|
export interface PersistedObservableStore<T> extends ObservableStore<T> {
|
|
9
|
-
/** Returns the next auto-incrementing ID and advances the counter. */
|
|
10
9
|
nextId: () => string;
|
|
10
|
+
ready: Promise<void>;
|
|
11
|
+
destroy: () => void;
|
|
11
12
|
}
|
|
12
13
|
export declare function createPersistedObservableStore<T extends {
|
|
13
14
|
id?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPersistedObservableStore.d.ts","sourceRoot":"","sources":["../../../../src/utils/createPersistedObservableStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAGtF,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC;CACnC;AAED,MAAM,WAAW,wBAAwB,CAAC,CAAC,CAAE,SAAQ,eAAe,CAAC,CAAC,CAAC;IACrE,
|
|
1
|
+
{"version":3,"file":"createPersistedObservableStore.d.ts","sourceRoot":"","sources":["../../../../src/utils/createPersistedObservableStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAGtF,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC;CACnC;AAED,MAAM,WAAW,wBAAwB,CAAC,CAAC,CAAE,SAAQ,eAAe,CAAC,CAAC,CAAC;IACrE,MAAM,EAAE,MAAM,MAAM,CAAC;IACrB,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACrB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,wBAAgB,8BAA8B,CAAC,CAAC,SAAS;IAAE,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,EACtE,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAChC,wBAAwB,CAAC,CAAC,CAAC,CAsE7B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type DaemonConnectionFailureReason = 'fetch_unavailable' | 'timeout' | 'http' | 'invalid_response' | 'network';
|
|
2
|
+
export type DaemonConnectionResult = {
|
|
3
|
+
ok: true;
|
|
4
|
+
endpoint: string;
|
|
5
|
+
status: number;
|
|
6
|
+
} | {
|
|
7
|
+
ok: false;
|
|
8
|
+
endpoint: string;
|
|
9
|
+
reason: DaemonConnectionFailureReason;
|
|
10
|
+
status?: number;
|
|
11
|
+
error?: string;
|
|
12
|
+
};
|
|
13
|
+
export interface DaemonConnectionOptions {
|
|
14
|
+
endpoint?: string;
|
|
15
|
+
timeoutMs?: number;
|
|
16
|
+
}
|
|
17
|
+
export declare function checkDaemonConnection(options?: DaemonConnectionOptions): Promise<DaemonConnectionResult>;
|
|
18
|
+
//# sourceMappingURL=daemonConnection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daemonConnection.d.ts","sourceRoot":"","sources":["../../../../src/utils/daemonConnection.ts"],"names":[],"mappings":"AAmBA,MAAM,MAAM,6BAA6B,GACrC,mBAAmB,GACnB,SAAS,GACT,MAAM,GACN,kBAAkB,GAClB,SAAS,CAAC;AAEd,MAAM,MAAM,sBAAsB,GAC9B;IACA,EAAE,EAAE,IAAI,CAAC;IACT,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,GACC;IACA,EAAE,EAAE,KAAK,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,6BAA6B,CAAC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEJ,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAoBD,wBAAsB,qBAAqB,CACzC,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,sBAAsB,CAAC,CAmEjC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const DAEMON_ENDPOINT_STORAGE_KEY = "debugToolkit_streamEndpoint";
|
|
2
|
+
export declare const DAEMON_TOKEN_STORAGE_KEY = "debugToolkit_streamToken";
|
|
3
|
+
export declare const DAEMON_CONNECTION_MODE_STORAGE_KEY = "debugToolkit_connectionMode";
|
|
4
|
+
export declare const DAEMON_DEVICE_HOST_STORAGE_KEY = "debugToolkit_deviceHost";
|
|
5
|
+
export type DaemonConnectionMode = 'simulator' | 'device';
|
|
6
|
+
export interface DaemonSettings {
|
|
7
|
+
mode: DaemonConnectionMode;
|
|
8
|
+
endpoint: string;
|
|
9
|
+
deviceHost: string;
|
|
10
|
+
token: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function loadDaemonSettings(): Promise<DaemonSettings>;
|
|
13
|
+
export declare function saveDaemonSettings(settings: DaemonSettings): Promise<void>;
|
|
14
|
+
export declare function buildDeviceDaemonEndpoint(host: string): string;
|
|
15
|
+
export declare function normalizeDaemonSettings(settings: DaemonSettings): {
|
|
16
|
+
endpoint?: string;
|
|
17
|
+
token?: string;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=daemonSettings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daemonSettings.d.ts","sourceRoot":"","sources":["../../../../src/utils/daemonSettings.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,2BAA2B,gCAAgC,CAAC;AACzE,eAAO,MAAM,wBAAwB,6BAA6B,CAAC;AACnE,eAAO,MAAM,kCAAkC,gCAAgC,CAAC;AAChF,eAAO,MAAM,8BAA8B,4BAA4B,CAAC;AAExE,MAAM,MAAM,oBAAoB,GAAG,WAAW,GAAG,QAAQ,CAAC;AAE1D,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,oBAAoB,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf;AAgBD,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,cAAc,CAAC,CA0BlE;AAED,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBhF;AA2BD,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAmB9D;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,cAAc,GAAG;IACjE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CASA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type DebugSessionReport, type DebugSessionReportOptions } from './sessionReport';
|
|
2
|
+
type FetchResponseLike = {
|
|
3
|
+
ok: boolean;
|
|
4
|
+
status: number;
|
|
5
|
+
json?: () => Promise<unknown>;
|
|
6
|
+
text?: () => Promise<string>;
|
|
7
|
+
};
|
|
8
|
+
type FetchLike = (url: string, init: {
|
|
9
|
+
method: string;
|
|
10
|
+
headers: Record<string, string>;
|
|
11
|
+
body?: string;
|
|
12
|
+
signal?: unknown;
|
|
13
|
+
}) => Promise<FetchResponseLike>;
|
|
14
|
+
export interface ReportToDaemonOptions extends DebugSessionReportOptions {
|
|
15
|
+
endpoint?: string;
|
|
16
|
+
timeoutMs?: number;
|
|
17
|
+
token?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface ReportResult {
|
|
20
|
+
ok: boolean;
|
|
21
|
+
endpoint: string;
|
|
22
|
+
report: DebugSessionReport;
|
|
23
|
+
status?: number;
|
|
24
|
+
sessionId?: string;
|
|
25
|
+
receivedAt?: string;
|
|
26
|
+
logCount?: Record<string, number>;
|
|
27
|
+
error?: string;
|
|
28
|
+
}
|
|
29
|
+
export declare function getGlobalFetch(): FetchLike | undefined;
|
|
30
|
+
export declare function getDefaultDaemonEndpoint(): string;
|
|
31
|
+
export declare function buildDaemonUrl(endpoint: string, path: string): string;
|
|
32
|
+
export declare function reportDebugSessionToDaemon(options?: ReportToDaemonOptions): Promise<ReportResult>;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=reportToDaemon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reportToDaemon.d.ts","sourceRoot":"","sources":["../../../../src/utils/reportToDaemon.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,EAC/B,MAAM,iBAAiB,CAAC;AAIzB,KAAK,iBAAiB,GAAG;IACvB,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;CAC9B,CAAC;AAEF,KAAK,SAAS,GAAG,CACf,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;IACJ,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,KACE,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAOhC,MAAM,WAAW,qBAAsB,SAAQ,yBAAyB;IACtE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,OAAO,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,cAAc,IAAI,SAAS,GAAG,SAAS,CAEtD;AASD,wBAAgB,wBAAwB,IAAI,MAAM,CAKjD;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAGrE;AAiCD,wBAAsB,0BAA0B,CAC9C,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,YAAY,CAAC,CAiEvB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface DebugSessionReportOptions {
|
|
2
|
+
maxPerType?: number;
|
|
3
|
+
maxBodyBytes?: number;
|
|
4
|
+
includeTypes?: string[];
|
|
5
|
+
}
|
|
6
|
+
export interface DeviceInfo {
|
|
7
|
+
platform: string;
|
|
8
|
+
model: string;
|
|
9
|
+
osVersion: string;
|
|
10
|
+
appVersion: string;
|
|
11
|
+
}
|
|
12
|
+
export interface DebugSessionReport {
|
|
13
|
+
version: 2;
|
|
14
|
+
device: DeviceInfo;
|
|
15
|
+
logs: Record<string, unknown[] | undefined>;
|
|
16
|
+
}
|
|
17
|
+
export declare function createDebugSessionReport(options?: DebugSessionReportOptions): DebugSessionReport;
|
|
18
|
+
//# sourceMappingURL=sessionReport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionReport.d.ts","sourceRoot":"","sources":["../../../../src/utils/sessionReport.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,yBAAyB;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,CAAC,CAAC;IACX,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,SAAS,CAAC,CAAC;CAC7C;AAuID,wBAAgB,wBAAwB,CACtC,OAAO,GAAE,yBAA8B,GACtC,kBAAkB,CAuCpB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface StreamToDaemonOptions {
|
|
2
|
+
endpoint?: string;
|
|
3
|
+
token?: string;
|
|
4
|
+
debounceMs?: number;
|
|
5
|
+
timeoutMs?: number;
|
|
6
|
+
onStatus?: (status: StreamStatus) => void;
|
|
7
|
+
}
|
|
8
|
+
export type StreamStatus = {
|
|
9
|
+
state: 'connecting';
|
|
10
|
+
} | {
|
|
11
|
+
state: 'connected';
|
|
12
|
+
sessionId: string;
|
|
13
|
+
} | {
|
|
14
|
+
state: 'retrying';
|
|
15
|
+
retryInMs: number;
|
|
16
|
+
} | {
|
|
17
|
+
state: 'failed';
|
|
18
|
+
reason: 'auth' | 'retry_limit';
|
|
19
|
+
};
|
|
20
|
+
export declare function startStreaming(options?: StreamToDaemonOptions): void;
|
|
21
|
+
export declare function stopStreaming(): void;
|
|
22
|
+
export declare function isStreaming(): boolean;
|
|
23
|
+
//# sourceMappingURL=streamToDaemon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streamToDaemon.d.ts","sourceRoot":"","sources":["../../../../src/utils/streamToDaemon.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;CAC3C;AAED,MAAM,MAAM,YAAY,GACpB;IAAE,KAAK,EAAE,YAAY,CAAA;CAAE,GACvB;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACzC;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACxC;IAAE,KAAK,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAAA;CAAE,CAAC;AAiVxD,wBAAgB,cAAc,CAAC,OAAO,GAAE,qBAA0B,GAAG,IAAI,CA0CxE;AAED,wBAAgB,aAAa,IAAI,IAAI,CASpC;AAED,wBAAgB,WAAW,IAAI,OAAO,CAErC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
DAEMON_NAME,
|
|
5
|
+
DEFAULT_HOST,
|
|
6
|
+
DEFAULT_PORT,
|
|
7
|
+
getLanIPs,
|
|
8
|
+
} = require('./constants');
|
|
9
|
+
const { createDaemonServer } = require('./server');
|
|
10
|
+
|
|
11
|
+
function readOption(args, name, fallback) {
|
|
12
|
+
const index = args.indexOf(name);
|
|
13
|
+
if (index < 0) {
|
|
14
|
+
return fallback;
|
|
15
|
+
}
|
|
16
|
+
return args[index + 1] || fallback;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function hasHelpFlag(args) {
|
|
20
|
+
return args.includes('--help') || args.includes('-h');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function printHelp() {
|
|
24
|
+
process.stdout.write('Usage: debug-toolkit-daemon [--host 0.0.0.0] [--port 3799] [--token dev-token]\n');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function getLocalOrigin(host, port) {
|
|
28
|
+
const localHost = host === '0.0.0.0' || host === '::' ? '127.0.0.1' : host;
|
|
29
|
+
return `http://${localHost}:${port}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function startDaemonFromCli(args) {
|
|
33
|
+
if (hasHelpFlag(args)) {
|
|
34
|
+
printHelp();
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const host = readOption(args, '--host', process.env.DEBUG_TOOLKIT_DAEMON_HOST || DEFAULT_HOST);
|
|
39
|
+
const port = Number(readOption(args, '--port', process.env.DEBUG_TOOLKIT_DAEMON_PORT || DEFAULT_PORT));
|
|
40
|
+
const token = readOption(args, '--token', process.env.DEBUG_TOOLKIT_DAEMON_TOKEN || '');
|
|
41
|
+
|
|
42
|
+
if (!Number.isFinite(port) || port <= 0) {
|
|
43
|
+
process.stderr.write('Invalid --port value\n');
|
|
44
|
+
process.exitCode = 1;
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const { server } = createDaemonServer({ token });
|
|
49
|
+
|
|
50
|
+
server.on('error', (error) => {
|
|
51
|
+
process.stderr.write(`${DAEMON_NAME} failed to start: ${error.message}\n`);
|
|
52
|
+
process.exitCode = 1;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
server.listen(port, host, () => {
|
|
56
|
+
const consolePath = token ? `/console?token=${encodeURIComponent(token)}` : '/console';
|
|
57
|
+
process.stderr.write(`${DAEMON_NAME} listening on http://${host}:${port}\n`);
|
|
58
|
+
process.stderr.write(`Web Console: ${getLocalOrigin(host, port)}${consolePath}\n`);
|
|
59
|
+
const lanIPs = getLanIPs();
|
|
60
|
+
if (lanIPs.length > 0) {
|
|
61
|
+
process.stderr.write(`LAN IPs: ${lanIPs.join(', ')}\n`);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const close = () => {
|
|
66
|
+
server.close(() => process.exit(0));
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
process.on('SIGINT', close);
|
|
70
|
+
process.on('SIGTERM', close);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
module.exports = {
|
|
74
|
+
startDaemonFromCli,
|
|
75
|
+
};
|