react-native-debug-toolkit 3.1.2 → 3.1.4
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 +4 -2
- package/README.zh-CN.md +4 -2
- package/lib/commonjs/core/DebugToolkit.js +118 -97
- package/lib/commonjs/core/DebugToolkit.js.map +1 -1
- package/lib/commonjs/core/initialize.js +4 -4
- package/lib/commonjs/core/initialize.js.map +1 -1
- package/lib/commonjs/features/environment/index.js +22 -24
- package/lib/commonjs/features/environment/index.js.map +1 -1
- package/lib/commonjs/features/network/index.js +25 -47
- package/lib/commonjs/features/network/index.js.map +1 -1
- package/lib/commonjs/features/network/networkInterceptor.js +3 -3
- package/lib/commonjs/features/network/networkInterceptor.js.map +1 -1
- package/lib/commonjs/index.js +0 -30
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/DaemonClient.js +13 -51
- package/lib/commonjs/utils/DaemonClient.js.map +1 -1
- package/lib/commonjs/utils/createChannelFeature.js +8 -1
- package/lib/commonjs/utils/createChannelFeature.js.map +1 -1
- package/lib/commonjs/utils/deviceReport.js +2 -1
- package/lib/commonjs/utils/deviceReport.js.map +1 -1
- package/lib/commonjs/utils/urlRewriter.js +15 -0
- package/lib/commonjs/utils/urlRewriter.js.map +1 -0
- package/lib/module/core/DebugToolkit.js +117 -96
- package/lib/module/core/DebugToolkit.js.map +1 -1
- package/lib/module/core/initialize.js +6 -7
- package/lib/module/core/initialize.js.map +1 -1
- package/lib/module/features/environment/index.js +22 -24
- package/lib/module/features/environment/index.js.map +1 -1
- package/lib/module/features/network/index.js +25 -46
- package/lib/module/features/network/index.js.map +1 -1
- package/lib/module/features/network/networkInterceptor.js +3 -3
- package/lib/module/features/network/networkInterceptor.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/DaemonClient.js +14 -42
- package/lib/module/utils/DaemonClient.js.map +1 -1
- package/lib/module/utils/createChannelFeature.js +8 -1
- package/lib/module/utils/createChannelFeature.js.map +1 -1
- package/lib/module/utils/deviceReport.js +3 -2
- package/lib/module/utils/deviceReport.js.map +1 -1
- package/lib/module/utils/urlRewriter.js +10 -0
- package/lib/module/utils/urlRewriter.js.map +1 -0
- package/lib/typescript/src/core/DebugToolkit.d.ts +23 -10
- package/lib/typescript/src/core/DebugToolkit.d.ts.map +1 -1
- package/lib/typescript/src/core/initialize.d.ts.map +1 -1
- package/lib/typescript/src/features/environment/index.d.ts.map +1 -1
- package/lib/typescript/src/features/network/index.d.ts +3 -3
- package/lib/typescript/src/features/network/index.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types/feature.d.ts +5 -0
- package/lib/typescript/src/types/feature.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +1 -1
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/DaemonClient.d.ts +4 -11
- package/lib/typescript/src/utils/DaemonClient.d.ts.map +1 -1
- package/lib/typescript/src/utils/createChannelFeature.d.ts +4 -0
- package/lib/typescript/src/utils/createChannelFeature.d.ts.map +1 -1
- package/lib/typescript/src/utils/deviceReport.d.ts +4 -1
- package/lib/typescript/src/utils/deviceReport.d.ts.map +1 -1
- package/lib/typescript/src/utils/urlRewriter.d.ts +5 -0
- package/lib/typescript/src/utils/urlRewriter.d.ts.map +1 -0
- package/node/daemon/src/console/console.html +324 -168
- package/node/daemon/src/server.js +32 -2
- package/node/mcp/src/logs.js +15 -4
- package/node/mcp/src/tools.js +4 -2
- package/package.json +1 -1
- package/src/core/DebugToolkit.tsx +119 -105
- package/src/core/initialize.ts +7 -8
- package/src/features/environment/index.ts +25 -27
- package/src/features/network/index.ts +30 -52
- package/src/features/network/networkInterceptor.ts +3 -3
- package/src/index.ts +3 -8
- package/src/types/feature.ts +6 -0
- package/src/types/index.ts +1 -0
- package/src/utils/DaemonClient.ts +14 -56
- package/src/utils/createChannelFeature.ts +12 -1
- package/src/utils/deviceReport.ts +5 -3
- package/src/utils/urlRewriter.ts +11 -0
- package/lib/commonjs/utils/urlRewriterRegistry.js +0 -14
- package/lib/commonjs/utils/urlRewriterRegistry.js.map +0 -1
- package/lib/module/utils/urlRewriterRegistry.js +0 -10
- package/lib/module/utils/urlRewriterRegistry.js.map +0 -1
- package/lib/typescript/src/utils/urlRewriterRegistry.d.ts +0 -7
- package/lib/typescript/src/utils/urlRewriterRegistry.d.ts.map +0 -1
- package/src/utils/urlRewriterRegistry.ts +0 -10
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { NetworkLogTab } from './NetworkLogTab';
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { NetworkLogEntry } from '../../types';
|
|
4
|
+
import { createChannelFeature } from '../../utils/createChannelFeature';
|
|
4
5
|
import { createEventChannel } from '../../utils/createEventChannel';
|
|
5
|
-
import { createPersistedObservableStore } from '../../utils/createPersistedObservableStore';
|
|
6
6
|
import { KEYS } from '../../utils/debugPreferences';
|
|
7
|
-
import { urlRewriter } from '../../utils/urlRewriterRegistry';
|
|
8
7
|
import {
|
|
9
8
|
startXMLHttpRequest,
|
|
10
9
|
resetInterceptors,
|
|
11
10
|
} from './networkInterceptor';
|
|
12
11
|
import type { NetworkLogPayload } from './networkInterceptor';
|
|
12
|
+
import { setUrlRewriter as setInterceptorUrlRewriter } from '../../utils/urlRewriter';
|
|
13
13
|
|
|
14
14
|
// ─── Utilities ────────────────────────────────────────
|
|
15
15
|
|
|
@@ -35,7 +35,6 @@ function emitNetworkLog(entry: NetworkLogPayload): void {
|
|
|
35
35
|
|
|
36
36
|
// ─── Feature factory ──────────────────────────────────
|
|
37
37
|
|
|
38
|
-
const DEFAULT_MAX_LOGS = 200;
|
|
39
38
|
const daemonEndpointBlacklist: Array<string | RegExp> = [];
|
|
40
39
|
|
|
41
40
|
export interface NetworkFeatureConfig {
|
|
@@ -45,54 +44,33 @@ export interface NetworkFeatureConfig {
|
|
|
45
44
|
blacklist?: Array<string | RegExp>;
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
export const createNetworkFeature = (config?: NetworkFeatureConfig)
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
unsubscribeLogs = networkChannel.subscribe(handleLog);
|
|
75
|
-
stopXhrFn = startXMLHttpRequest(emitNetworkLog);
|
|
76
|
-
initialized = true;
|
|
47
|
+
export const createNetworkFeature = (config?: NetworkFeatureConfig) => {
|
|
48
|
+
const userBlacklist = config?.blacklist ? [...config.blacklist] : [];
|
|
49
|
+
|
|
50
|
+
return createChannelFeature<NetworkLogPayload, NetworkLogEntry>(
|
|
51
|
+
() => networkChannel,
|
|
52
|
+
(payload, id) => ({ ...payload, id }),
|
|
53
|
+
{
|
|
54
|
+
name: 'network',
|
|
55
|
+
label: 'Network',
|
|
56
|
+
renderContent: NetworkLogTab,
|
|
57
|
+
maxLogs: config?.maxLogs,
|
|
58
|
+
persist: { storageKey: KEYS.networkLogs, maxPersist: 30 },
|
|
59
|
+
beforePush: (payload) => {
|
|
60
|
+
if (isUrlBlacklisted(payload.request.url, [...userBlacklist, ...daemonEndpointBlacklist])) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
return payload;
|
|
64
|
+
},
|
|
65
|
+
onSetup: () => {
|
|
66
|
+
const stopXhr = startXMLHttpRequest(emitNetworkLog);
|
|
67
|
+
return () => {
|
|
68
|
+
setInterceptorUrlRewriter(null);
|
|
69
|
+
stopXhr();
|
|
70
|
+
};
|
|
71
|
+
},
|
|
77
72
|
},
|
|
78
|
-
|
|
79
|
-
clear: () => {
|
|
80
|
-
logStore.clear();
|
|
81
|
-
},
|
|
82
|
-
cleanup: () => {
|
|
83
|
-
if (!initialized) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
urlRewriter.set(null);
|
|
87
|
-
unsubscribeLogs?.();
|
|
88
|
-
unsubscribeLogs = null;
|
|
89
|
-
stopXhrFn?.();
|
|
90
|
-
stopXhrFn = null;
|
|
91
|
-
logStore.clear();
|
|
92
|
-
initialized = false;
|
|
93
|
-
},
|
|
94
|
-
subscribe: (listener) => logStore.subscribe(listener),
|
|
95
|
-
};
|
|
73
|
+
);
|
|
96
74
|
};
|
|
97
75
|
|
|
98
76
|
function normalizeDaemonEndpoint(endpoint: string): string {
|
|
@@ -109,7 +87,7 @@ function normalizeDaemonEndpoint(endpoint: string): string {
|
|
|
109
87
|
}
|
|
110
88
|
}
|
|
111
89
|
|
|
112
|
-
export function
|
|
90
|
+
export function addToBlacklist(endpoint: string): void {
|
|
113
91
|
const normalized = normalizeDaemonEndpoint(endpoint);
|
|
114
92
|
if (!normalized || daemonEndpointBlacklist.includes(normalized)) {
|
|
115
93
|
return;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NetworkLogEntry } from '../../types';
|
|
2
|
-
import {
|
|
2
|
+
import { getUrlRewriter } from '../../utils/urlRewriter';
|
|
3
3
|
|
|
4
4
|
type NetworkLogPayload = Omit<NetworkLogEntry, 'id'>;
|
|
5
5
|
|
|
@@ -11,7 +11,7 @@ export type { NetworkLogPayload };
|
|
|
11
11
|
// ─── Shared helpers ────────────────────────────────────
|
|
12
12
|
|
|
13
13
|
function rewriteUrl(url: string): string {
|
|
14
|
-
const rewriter =
|
|
14
|
+
const rewriter = getUrlRewriter();
|
|
15
15
|
if (!rewriter) {
|
|
16
16
|
return url;
|
|
17
17
|
}
|
|
@@ -193,7 +193,7 @@ export function startXMLHttpRequest(
|
|
|
193
193
|
url: string,
|
|
194
194
|
...args: unknown[]
|
|
195
195
|
) {
|
|
196
|
-
const rewrittenUrl =
|
|
196
|
+
const rewrittenUrl = rewriteUrl(url);
|
|
197
197
|
if (shouldIgnoreUrl(rewrittenUrl)) {
|
|
198
198
|
return originalXhrOpen!.call(this, method, rewrittenUrl, ...args);
|
|
199
199
|
}
|
package/src/index.ts
CHANGED
|
@@ -42,21 +42,16 @@ export type {
|
|
|
42
42
|
ReportResult,
|
|
43
43
|
ReportToDaemonOptions,
|
|
44
44
|
} from './utils/DaemonClient';
|
|
45
|
-
export {
|
|
46
|
-
getDefaultDaemonEndpoint,
|
|
47
|
-
reportDebugDeviceToDaemon,
|
|
48
|
-
checkDaemonConnection,
|
|
49
|
-
startStreaming,
|
|
50
|
-
stopStreaming,
|
|
51
|
-
isStreaming,
|
|
52
|
-
} from './utils/DaemonClient';
|
|
45
|
+
export { getDefaultDaemonEndpoint } from './utils/DaemonClient';
|
|
53
46
|
|
|
54
47
|
// Types
|
|
55
48
|
export type {
|
|
56
49
|
AnyDebugFeature,
|
|
57
50
|
BuiltInFeatureName,
|
|
58
51
|
DebugFeature,
|
|
52
|
+
DebugFeatureListener,
|
|
59
53
|
DebugFeatureRenderProps,
|
|
54
|
+
FeatureDataProvider,
|
|
60
55
|
NetworkLogEntry,
|
|
61
56
|
ConsoleLogEntry,
|
|
62
57
|
ZustandLogEntry,
|
package/src/types/feature.ts
CHANGED
|
@@ -19,6 +19,12 @@ export interface DebugFeatureRenderProps<TSnapshot = unknown> {
|
|
|
19
19
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
20
|
export type AnyDebugFeature = DebugFeature<any>;
|
|
21
21
|
|
|
22
|
+
/** Provides feature list and change notifications to consumers (e.g., DaemonClient). */
|
|
23
|
+
export interface FeatureDataProvider {
|
|
24
|
+
readonly features: AnyDebugFeature[];
|
|
25
|
+
subscribe(listener: DebugFeatureListener): () => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
22
28
|
export interface DebugFeature<TSnapshot = unknown> {
|
|
23
29
|
name: string;
|
|
24
30
|
label: string;
|
package/src/types/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AppState, type AppStateStatus, Platform } from 'react-native';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { debugToolkit } from '../core/DebugToolkit';
|
|
4
|
+
import type { FeatureDataProvider } from '../types';
|
|
4
5
|
import {
|
|
5
6
|
createDebugDeviceReport,
|
|
6
7
|
type DebugDeviceReport,
|
|
@@ -164,6 +165,7 @@ interface StreamState {
|
|
|
164
165
|
export interface DaemonClientOptions {
|
|
165
166
|
fetch?: FetchLike;
|
|
166
167
|
AbortController?: AbortControllerCtor;
|
|
168
|
+
featureProvider: FeatureDataProvider;
|
|
167
169
|
onEndpointDetected?: (url: string) => void;
|
|
168
170
|
}
|
|
169
171
|
|
|
@@ -178,13 +180,15 @@ export class DaemonClient {
|
|
|
178
180
|
private _stream: StreamState | null = null;
|
|
179
181
|
private _fetch: FetchLike | undefined;
|
|
180
182
|
private _AbortController: AbortControllerCtor | undefined;
|
|
183
|
+
private _featureProvider: FeatureDataProvider;
|
|
181
184
|
private _onEndpointDetected: ((url: string) => void) | undefined;
|
|
182
185
|
private _restorePromise: Promise<void> | null = null;
|
|
183
186
|
|
|
184
|
-
constructor(options
|
|
185
|
-
this._fetch = options
|
|
186
|
-
this._AbortController = options
|
|
187
|
-
this.
|
|
187
|
+
constructor(options: DaemonClientOptions) {
|
|
188
|
+
this._fetch = options.fetch;
|
|
189
|
+
this._AbortController = options.AbortController;
|
|
190
|
+
this._featureProvider = options.featureProvider;
|
|
191
|
+
this._onEndpointDetected = options.onEndpointDetected;
|
|
188
192
|
}
|
|
189
193
|
|
|
190
194
|
// --- Settings ---
|
|
@@ -291,7 +295,7 @@ export class DaemonClient {
|
|
|
291
295
|
onStatus: options.onStatus,
|
|
292
296
|
};
|
|
293
297
|
|
|
294
|
-
for (const feature of
|
|
298
|
+
for (const feature of this._featureProvider.features) {
|
|
295
299
|
if (!feature.subscribe) continue;
|
|
296
300
|
const unsub = feature.subscribe(() => { this.onFeatureChange(feature.name); });
|
|
297
301
|
state.featureUnsubscribes.push(unsub);
|
|
@@ -625,7 +629,7 @@ export class DaemonClient {
|
|
|
625
629
|
}
|
|
626
630
|
|
|
627
631
|
private async doSendFullReport(state: StreamState): Promise<SendResult> {
|
|
628
|
-
const report = createDebugDeviceReport();
|
|
632
|
+
const report = createDebugDeviceReport({ featureProvider: this._featureProvider });
|
|
629
633
|
const response = await this.doPost(
|
|
630
634
|
state.reportUrl,
|
|
631
635
|
this.fetchHeaders(state),
|
|
@@ -648,7 +652,7 @@ export class DaemonClient {
|
|
|
648
652
|
}
|
|
649
653
|
|
|
650
654
|
state.lastSentIds.clear();
|
|
651
|
-
for (const feature of
|
|
655
|
+
for (const feature of this._featureProvider.features) {
|
|
652
656
|
try {
|
|
653
657
|
const snapshot = feature.getSnapshot();
|
|
654
658
|
if (Array.isArray(snapshot)) {
|
|
@@ -673,7 +677,7 @@ export class DaemonClient {
|
|
|
673
677
|
try {
|
|
674
678
|
const delta: Record<string, unknown[]> = {};
|
|
675
679
|
const nextSentIds = new Map<string, Set<string | number>>();
|
|
676
|
-
const features =
|
|
680
|
+
const features = this._featureProvider.features;
|
|
677
681
|
|
|
678
682
|
for (const featureName of state.dirtyFeatures) {
|
|
679
683
|
const feature = features.find((f) => f.name === featureName);
|
|
@@ -769,53 +773,7 @@ export class DaemonClient {
|
|
|
769
773
|
|
|
770
774
|
// ---- Module-level Singleton ----
|
|
771
775
|
|
|
772
|
-
export const daemonClient = new DaemonClient();
|
|
773
|
-
|
|
774
|
-
// ---- Backward-compatible Function Exports ----
|
|
775
|
-
|
|
776
|
-
export async function loadDaemonSettings(): Promise<DaemonSettings> {
|
|
777
|
-
return daemonClient.getSettings();
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
export async function saveDaemonSettings(settings: DaemonSettings): Promise<void> {
|
|
781
|
-
daemonClient.configure(settings);
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
export async function loadDaemonStreamingEnabled(): Promise<boolean | null> {
|
|
785
|
-
return null;
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
export async function saveDaemonStreamingEnabled(enabled: boolean): Promise<void> {
|
|
789
|
-
daemonClient.setStreamingEnabled(enabled);
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
export function startStreaming(options: StreamToDaemonOptions = {}): void {
|
|
793
|
-
daemonClient.connect(options);
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
export function stopStreaming(): void {
|
|
797
|
-
daemonClient.disconnect();
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
export function isStreaming(): boolean {
|
|
801
|
-
return daemonClient.isConnected();
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
export function checkDaemonConnection(
|
|
805
|
-
options: DaemonConnectionOptions = {},
|
|
806
|
-
): Promise<DaemonConnectionResult> {
|
|
807
|
-
return daemonClient.checkConnection(options);
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
export function reportDebugDeviceToDaemon(
|
|
811
|
-
options: ReportToDaemonOptions = {},
|
|
812
|
-
): Promise<ReportResult> {
|
|
813
|
-
return daemonClient.reportOnce(options);
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
export function restoreDaemonStreaming(): Promise<void> {
|
|
817
|
-
return daemonClient.restore();
|
|
818
|
-
}
|
|
776
|
+
export const daemonClient = new DaemonClient({ featureProvider: debugToolkit });
|
|
819
777
|
|
|
820
778
|
// ---- Internal Helpers ----
|
|
821
779
|
|
|
@@ -30,6 +30,10 @@ export function createChannelFeature<TPayload, TEntry extends { id?: string }>(
|
|
|
30
30
|
renderContent?: ComponentType<DebugFeatureRenderProps<TEntry[]>>;
|
|
31
31
|
maxLogs?: number;
|
|
32
32
|
persist?: ChannelFeaturePersistConfig<TEntry>;
|
|
33
|
+
/** Return null to skip, or the (possibly modified) payload to proceed. */
|
|
34
|
+
beforePush?: (payload: TPayload) => TPayload | null;
|
|
35
|
+
/** Called after channel subscription in setup. Return a cleanup function. */
|
|
36
|
+
onSetup?: () => (() => void) | void;
|
|
33
37
|
},
|
|
34
38
|
): DebugFeature<TEntry[]> {
|
|
35
39
|
const maxLogs = options.maxLogs ?? DEFAULT_MAX_LOGS;
|
|
@@ -53,6 +57,7 @@ export function createChannelFeature<TPayload, TEntry extends { id?: string }>(
|
|
|
53
57
|
|
|
54
58
|
let initialized = false;
|
|
55
59
|
let unsubscribe: (() => void) | null = null;
|
|
60
|
+
let customCleanup: (() => void) | null = null;
|
|
56
61
|
|
|
57
62
|
return {
|
|
58
63
|
name: options.name,
|
|
@@ -61,8 +66,12 @@ export function createChannelFeature<TPayload, TEntry extends { id?: string }>(
|
|
|
61
66
|
setup: () => {
|
|
62
67
|
if (initialized) return;
|
|
63
68
|
unsubscribe = getChannel().subscribe((payload) => {
|
|
64
|
-
|
|
69
|
+
const filtered = options.beforePush ? options.beforePush(payload) : payload;
|
|
70
|
+
if (filtered == null) return;
|
|
71
|
+
logStore.push(toEntry(filtered, getId()), maxLogs);
|
|
65
72
|
});
|
|
73
|
+
const cleanup = options.onSetup?.();
|
|
74
|
+
if (cleanup) customCleanup = cleanup;
|
|
66
75
|
initialized = true;
|
|
67
76
|
},
|
|
68
77
|
getSnapshot: () => logStore.getData(),
|
|
@@ -70,6 +79,8 @@ export function createChannelFeature<TPayload, TEntry extends { id?: string }>(
|
|
|
70
79
|
logStore.clear();
|
|
71
80
|
},
|
|
72
81
|
cleanup: () => {
|
|
82
|
+
customCleanup?.();
|
|
83
|
+
customCleanup = null;
|
|
73
84
|
unsubscribe?.();
|
|
74
85
|
unsubscribe = null;
|
|
75
86
|
logStore.clear();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Platform } from 'react-native';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { debugToolkit } from '../core/DebugToolkit';
|
|
4
|
+
import type { FeatureDataProvider } from '../types';
|
|
4
5
|
import { safeStringify } from './safeStringify';
|
|
5
6
|
|
|
6
7
|
const DEFAULT_MAX_PER_TYPE = 50;
|
|
@@ -160,14 +161,15 @@ function sanitizeValue(
|
|
|
160
161
|
}
|
|
161
162
|
|
|
162
163
|
export function createDebugDeviceReport(
|
|
163
|
-
options: DebugDeviceReportOptions = {},
|
|
164
|
+
options: DebugDeviceReportOptions & { featureProvider?: FeatureDataProvider } = {},
|
|
164
165
|
): DebugDeviceReport {
|
|
166
|
+
const provider = options.featureProvider ?? debugToolkit;
|
|
165
167
|
const maxPerType = Math.max(1, Math.floor(options.maxPerType ?? DEFAULT_MAX_PER_TYPE));
|
|
166
168
|
const maxBodyBytes = Math.max(256, Math.floor(options.maxBodyBytes ?? DEFAULT_MAX_BODY_BYTES));
|
|
167
169
|
const includeTypes = options.includeTypes?.length ? new Set(options.includeTypes) : null;
|
|
168
170
|
const logs: DebugDeviceReport['logs'] = {};
|
|
169
171
|
|
|
170
|
-
|
|
172
|
+
provider.features.forEach((feature) => {
|
|
171
173
|
if (includeTypes && !includeTypes.has(feature.name)) {
|
|
172
174
|
return;
|
|
173
175
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type UrlRewriter = (url: string) => string;
|
|
2
|
+
|
|
3
|
+
let _urlRewriter: UrlRewriter | null = null;
|
|
4
|
+
|
|
5
|
+
export function getUrlRewriter(): UrlRewriter | null {
|
|
6
|
+
return _urlRewriter;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function setUrlRewriter(rewriter: UrlRewriter | null): void {
|
|
10
|
+
_urlRewriter = rewriter;
|
|
11
|
+
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.urlRewriter = void 0;
|
|
7
|
-
let current = null;
|
|
8
|
-
const urlRewriter = exports.urlRewriter = {
|
|
9
|
-
get: () => current,
|
|
10
|
-
set: rewriter => {
|
|
11
|
-
current = rewriter;
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=urlRewriterRegistry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["current","urlRewriter","exports","get","set","rewriter"],"sourceRoot":"../../../src","sources":["utils/urlRewriterRegistry.ts"],"mappings":";;;;;;AAEA,IAAIA,OAA2B,GAAG,IAAI;AAE/B,MAAMC,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG;EACzBE,GAAG,EAAEA,CAAA,KAA0BH,OAAO;EACtCI,GAAG,EAAGC,QAA4B,IAAW;IAC3CL,OAAO,GAAGK,QAAQ;EACpB;AACF,CAAC","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["current","urlRewriter","get","set","rewriter"],"sourceRoot":"../../../src","sources":["utils/urlRewriterRegistry.ts"],"mappings":";;AAEA,IAAIA,OAA2B,GAAG,IAAI;AAEtC,OAAO,MAAMC,WAAW,GAAG;EACzBC,GAAG,EAAEA,CAAA,KAA0BF,OAAO;EACtCG,GAAG,EAAGC,QAA4B,IAAW;IAC3CJ,OAAO,GAAGI,QAAQ;EACpB;AACF,CAAC","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"urlRewriterRegistry.d.ts","sourceRoot":"","sources":["../../../../src/utils/urlRewriterRegistry.ts"],"names":[],"mappings":"AAAA,KAAK,WAAW,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;AAI3C,eAAO,MAAM,WAAW;eACb,WAAW,GAAG,IAAI;oBACX,WAAW,GAAG,IAAI,KAAG,IAAI;CAG1C,CAAC"}
|