@rozenite/network-activity-plugin 1.5.1 → 1.7.0-rc.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/CHANGELOG.md +20 -0
- package/README.md +2 -0
- package/dist/{App.html → devtools/App.html} +2 -2
- package/dist/{boot-recording.cjs → react-native/chunks/boot-recording.cjs} +1 -1
- package/dist/{boot-recording.js → react-native/chunks/boot-recording.js} +3 -3
- package/dist/react-native/chunks/boot-recording.require.cjs +5 -0
- package/dist/react-native/chunks/boot-recording.require.js +5 -0
- package/dist/react-native/chunks/useNetworkActivityDevTools.require.cjs +1102 -0
- package/dist/react-native/chunks/useNetworkActivityDevTools.require.js +1102 -0
- package/dist/{react-native.cjs → react-native/index.cjs} +2 -2
- package/dist/react-native/index.d.ts +305 -0
- package/dist/{react-native.js → react-native/index.js} +2 -2
- package/dist/rozenite.json +1 -1
- package/package.json +27 -7
- package/src/react-native/agent/__tests__/network-activity-agent-state.test.ts +250 -0
- package/src/react-native/agent/state.ts +869 -0
- package/src/react-native/agent/tools.ts +146 -0
- package/src/react-native/agent/use-network-activity-agent-tools.ts +244 -0
- package/src/react-native/http/http-inspector.ts +0 -1
- package/src/react-native/useNetworkActivityDevTools.ts +11 -0
- package/tsconfig.json +3 -0
- package/dist/react-native.d.ts +0 -4
- package/dist/rozenite.config.d.ts +0 -7
- package/dist/src/react-native/boot-recording.d.ts +0 -41
- package/dist/src/react-native/config.d.ts +0 -23
- package/dist/src/react-native/events-listener.d.ts +0 -44
- package/dist/src/react-native/http/http-inspector.d.ts +0 -10
- package/dist/src/react-native/http/http-utils.d.ts +0 -15
- package/dist/src/react-native/http/network-requests-registry.d.ts +0 -6
- package/dist/src/react-native/http/overrides-registry.d.ts +0 -6
- package/dist/src/react-native/http/xhr-interceptor.d.ts +0 -44
- package/dist/src/react-native/inspector.d.ts +0 -7
- package/dist/src/react-native/network-inspector.d.ts +0 -16
- package/dist/src/react-native/sse/event-source.d.ts +0 -2
- package/dist/src/react-native/sse/sse-inspector.d.ts +0 -6
- package/dist/src/react-native/sse/sse-interceptor.d.ts +0 -36
- package/dist/src/react-native/sse/types.d.ts +0 -6
- package/dist/src/react-native/useHttpInspector.d.ts +0 -3
- package/dist/src/react-native/useNetworkActivityDevTools.d.ts +0 -3
- package/dist/src/react-native/useSSEInspector.d.ts +0 -3
- package/dist/src/react-native/useWebSocketInspector.d.ts +0 -3
- package/dist/src/react-native/utils/getBlobName.d.ts +0 -35
- package/dist/src/react-native/utils/getFormDataEntries.d.ts +0 -18
- package/dist/src/react-native/utils.d.ts +0 -6
- package/dist/src/react-native/websocket/websocket-inspector.d.ts +0 -6
- package/dist/src/react-native/websocket/websocket-interceptor.d.ts +0 -73
- package/dist/src/shared/client.d.ts +0 -17
- package/dist/src/shared/http-events.d.ts +0 -106
- package/dist/src/shared/sse-events.d.ts +0 -38
- package/dist/src/shared/websocket-events.d.ts +0 -60
- package/dist/src/ui/App.d.ts +0 -1
- package/dist/src/ui/components/Badge.d.ts +0 -9
- package/dist/src/ui/components/Button.d.ts +0 -11
- package/dist/src/ui/components/CodeBlock.d.ts +0 -3
- package/dist/src/ui/components/CodeEditor.d.ts +0 -5
- package/dist/src/ui/components/CookieCard.d.ts +0 -7
- package/dist/src/ui/components/CopyRequestDropdown.d.ts +0 -7
- package/dist/src/ui/components/DropdownMenu.d.ts +0 -27
- package/dist/src/ui/components/FilterBar.d.ts +0 -10
- package/dist/src/ui/components/Input.d.ts +0 -3
- package/dist/src/ui/components/JsonTree.d.ts +0 -5
- package/dist/src/ui/components/JsonTreeCopyableItem.d.ts +0 -7
- package/dist/src/ui/components/KeyValueGrid.d.ts +0 -13
- package/dist/src/ui/components/OverrideResponse.d.ts +0 -8
- package/dist/src/ui/components/RequestBody.d.ts +0 -6
- package/dist/src/ui/components/RequestList.d.ts +0 -30
- package/dist/src/ui/components/ScrollArea.d.ts +0 -5
- package/dist/src/ui/components/Section.d.ts +0 -8
- package/dist/src/ui/components/Separator.d.ts +0 -4
- package/dist/src/ui/components/SidePanel.d.ts +0 -1
- package/dist/src/ui/components/Tabs.d.ts +0 -7
- package/dist/src/ui/components/Toolbar.d.ts +0 -1
- package/dist/src/ui/hooks/useCopyToClipboard.d.ts +0 -4
- package/dist/src/ui/state/derived.d.ts +0 -5
- package/dist/src/ui/state/hooks.d.ts +0 -21
- package/dist/src/ui/state/model.d.ts +0 -113
- package/dist/src/ui/state/store.d.ts +0 -48
- package/dist/src/ui/tabs/CookiesTab.d.ts +0 -5
- package/dist/src/ui/tabs/HeadersTab.d.ts +0 -5
- package/dist/src/ui/tabs/MessagesTab.d.ts +0 -5
- package/dist/src/ui/tabs/RequestTab.d.ts +0 -5
- package/dist/src/ui/tabs/ResponseTab.d.ts +0 -6
- package/dist/src/ui/tabs/SSEMessagesTab.d.ts +0 -5
- package/dist/src/ui/tabs/TimingTab.d.ts +0 -5
- package/dist/src/ui/types.d.ts +0 -26
- package/dist/src/ui/utils/assert.d.ts +0 -1
- package/dist/src/ui/utils/checkRequestBodyBinary.d.ts +0 -2
- package/dist/src/ui/utils/cn.d.ts +0 -2
- package/dist/src/ui/utils/copyToClipboard.d.ts +0 -1
- package/dist/src/ui/utils/escapeShellArg.d.ts +0 -1
- package/dist/src/ui/utils/generateCurlCommand.d.ts +0 -2
- package/dist/src/ui/utils/generateFetchCall.d.ts +0 -2
- package/dist/src/ui/utils/generateMultipartBody.d.ts +0 -4
- package/dist/src/ui/utils/getId.d.ts +0 -1
- package/dist/src/ui/utils/getStatusColor.d.ts +0 -1
- package/dist/src/ui/views/InspectorView.d.ts +0 -5
- package/dist/src/ui/views/LoadingView.d.ts +0 -1
- package/dist/src/utils/applyReactNativeRequestHeadersLogic.d.ts +0 -7
- package/dist/src/utils/applyReactNativeResponseHeadersLogic.d.ts +0 -9
- package/dist/src/utils/cookieParser.d.ts +0 -6
- package/dist/src/utils/getContentTypeMimeType.d.ts +0 -2
- package/dist/src/utils/getHttpHeader.d.ts +0 -5
- package/dist/src/utils/getHttpHeaderValueAsString.d.ts +0 -11
- package/dist/src/utils/getStringSizeInBytes.d.ts +0 -1
- package/dist/src/utils/inferContentTypeFromPostData.d.ts +0 -2
- package/dist/src/utils/safeStringify.d.ts +0 -1
- package/dist/src/utils/typeChecks.d.ts +0 -9
- package/dist/useNetworkActivityDevTools.cjs +0 -171
- package/dist/useNetworkActivityDevTools.js +0 -171
- /package/dist/{assets → devtools/assets}/App-BrSkOkws.css +0 -0
- /package/dist/{assets/App-CGt4qucR.js → devtools/assets/App-pokLiGYV.js} +0 -0
- /package/dist/{event-source.cjs → react-native/chunks/event-source.cjs} +0 -0
- /package/dist/{event-source.js → react-native/chunks/event-source.js} +0 -0
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from "react";
|
|
2
|
-
import { useRozeniteDevToolsClient } from "@rozenite/plugin-bridge";
|
|
3
|
-
import { g as getOverridesRegistry, a as getResponseBody, c as createNetworkInspectorsConfiguration, D as DEFAULT_CONFIG, v as validateConfig, i as isHttpEvent, b as isWebSocketEvent, d as isSSEEvent } from "./boot-recording.js";
|
|
4
|
-
const overridesRegistry = getOverridesRegistry();
|
|
5
|
-
const useHttpInspector = (client, httpInspector, isEnabled, isRecordingEnabled) => {
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
if (!client || !isEnabled) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
const networkRequestsRegistry = httpInspector.getNetworkRequestsRegistry();
|
|
11
|
-
const subscriptions = [
|
|
12
|
-
client.onMessage("network-enable", () => {
|
|
13
|
-
httpInspector.enable();
|
|
14
|
-
}),
|
|
15
|
-
client.onMessage("network-disable", () => {
|
|
16
|
-
httpInspector.disable();
|
|
17
|
-
}),
|
|
18
|
-
client.onMessage("set-overrides", (data) => {
|
|
19
|
-
overridesRegistry.setOverrides(data.overrides);
|
|
20
|
-
}),
|
|
21
|
-
client.onMessage("get-response-body", async ({ requestId }) => {
|
|
22
|
-
const request = networkRequestsRegistry.getEntry(requestId);
|
|
23
|
-
if (!request) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
const body = await getResponseBody(request);
|
|
27
|
-
client.send("response-body", {
|
|
28
|
-
requestId,
|
|
29
|
-
body
|
|
30
|
-
});
|
|
31
|
-
})
|
|
32
|
-
];
|
|
33
|
-
if (isRecordingEnabled) {
|
|
34
|
-
httpInspector.enable();
|
|
35
|
-
}
|
|
36
|
-
return () => {
|
|
37
|
-
subscriptions.forEach((subscription) => subscription.remove());
|
|
38
|
-
httpInspector.dispose();
|
|
39
|
-
};
|
|
40
|
-
}, [client, httpInspector, isEnabled, isRecordingEnabled]);
|
|
41
|
-
};
|
|
42
|
-
const useWebSocketInspector = (client, websocketInspector, isEnabled, isRecordingEnabled) => {
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
if (!client || !isEnabled) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
const subscriptions = [
|
|
48
|
-
client.onMessage("network-enable", () => {
|
|
49
|
-
websocketInspector.enable();
|
|
50
|
-
}),
|
|
51
|
-
client.onMessage("network-disable", () => {
|
|
52
|
-
websocketInspector.disable();
|
|
53
|
-
})
|
|
54
|
-
];
|
|
55
|
-
if (isRecordingEnabled) {
|
|
56
|
-
websocketInspector.enable();
|
|
57
|
-
}
|
|
58
|
-
return () => {
|
|
59
|
-
subscriptions.forEach((subscription) => subscription.remove());
|
|
60
|
-
websocketInspector.dispose();
|
|
61
|
-
};
|
|
62
|
-
}, [client, websocketInspector, isEnabled, isRecordingEnabled]);
|
|
63
|
-
};
|
|
64
|
-
const useSSEInspector = (client, sseInspector, isEnabled, isRecordingEnabled) => {
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
if (!client || !isEnabled) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
const subscriptions = [
|
|
70
|
-
client.onMessage("network-enable", () => {
|
|
71
|
-
sseInspector.enable();
|
|
72
|
-
}),
|
|
73
|
-
client.onMessage("network-disable", () => {
|
|
74
|
-
sseInspector.disable();
|
|
75
|
-
})
|
|
76
|
-
];
|
|
77
|
-
if (isRecordingEnabled) {
|
|
78
|
-
sseInspector.enable();
|
|
79
|
-
}
|
|
80
|
-
return () => {
|
|
81
|
-
subscriptions.forEach((subscription) => subscription.remove());
|
|
82
|
-
sseInspector.dispose();
|
|
83
|
-
};
|
|
84
|
-
}, [client, sseInspector, isEnabled, isRecordingEnabled]);
|
|
85
|
-
};
|
|
86
|
-
const inspectorsConfig = createNetworkInspectorsConfiguration();
|
|
87
|
-
const useNetworkActivityDevTools = (config = DEFAULT_CONFIG) => {
|
|
88
|
-
const isRecordingEnabledRef = useRef(false);
|
|
89
|
-
const client = useRozeniteDevToolsClient({
|
|
90
|
-
pluginId: "@rozenite/network-activity-plugin"
|
|
91
|
-
});
|
|
92
|
-
const isHttpInspectorEnabled = config.inspectors?.http ?? true;
|
|
93
|
-
const isWebSocketInspectorEnabled = config.inspectors?.websocket ?? true;
|
|
94
|
-
const isSSEInspectorEnabled = config.inspectors?.sse ?? true;
|
|
95
|
-
const showUrlAsName = config.clientUISettings?.showUrlAsName;
|
|
96
|
-
const { eventsListener, networkInspector } = inspectorsConfig;
|
|
97
|
-
useEffect(() => {
|
|
98
|
-
if (!client) {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
validateConfig(config);
|
|
102
|
-
}, [config]);
|
|
103
|
-
useEffect(() => {
|
|
104
|
-
if (!client) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
const sendClientUISettings = () => {
|
|
108
|
-
client.send("client-ui-settings", {
|
|
109
|
-
settings: {
|
|
110
|
-
showUrlAsName: showUrlAsName ?? DEFAULT_CONFIG.clientUISettings?.showUrlAsName
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
};
|
|
114
|
-
const subscriptions = [
|
|
115
|
-
client.onMessage("network-enable", () => {
|
|
116
|
-
isRecordingEnabledRef.current = true;
|
|
117
|
-
eventsListener.connect(client.send, (message) => {
|
|
118
|
-
const type = message.type;
|
|
119
|
-
if (isHttpEvent(type)) {
|
|
120
|
-
return isHttpInspectorEnabled;
|
|
121
|
-
}
|
|
122
|
-
if (isWebSocketEvent(type)) {
|
|
123
|
-
return isWebSocketInspectorEnabled;
|
|
124
|
-
}
|
|
125
|
-
if (isSSEEvent(type)) {
|
|
126
|
-
return isSSEInspectorEnabled;
|
|
127
|
-
}
|
|
128
|
-
return true;
|
|
129
|
-
});
|
|
130
|
-
}),
|
|
131
|
-
client.onMessage("network-disable", () => {
|
|
132
|
-
isRecordingEnabledRef.current = false;
|
|
133
|
-
}),
|
|
134
|
-
client.onMessage("get-client-ui-settings", () => {
|
|
135
|
-
sendClientUISettings();
|
|
136
|
-
})
|
|
137
|
-
];
|
|
138
|
-
sendClientUISettings();
|
|
139
|
-
return () => {
|
|
140
|
-
subscriptions.forEach((subscription) => subscription.remove());
|
|
141
|
-
};
|
|
142
|
-
}, [
|
|
143
|
-
client,
|
|
144
|
-
showUrlAsName,
|
|
145
|
-
isHttpInspectorEnabled,
|
|
146
|
-
isWebSocketInspectorEnabled,
|
|
147
|
-
isSSEInspectorEnabled
|
|
148
|
-
]);
|
|
149
|
-
useHttpInspector(
|
|
150
|
-
client,
|
|
151
|
-
networkInspector.http,
|
|
152
|
-
isHttpInspectorEnabled,
|
|
153
|
-
isRecordingEnabledRef.current
|
|
154
|
-
);
|
|
155
|
-
useWebSocketInspector(
|
|
156
|
-
client,
|
|
157
|
-
networkInspector.websocket,
|
|
158
|
-
isWebSocketInspectorEnabled,
|
|
159
|
-
isRecordingEnabledRef.current
|
|
160
|
-
);
|
|
161
|
-
useSSEInspector(
|
|
162
|
-
client,
|
|
163
|
-
networkInspector.sse,
|
|
164
|
-
isSSEInspectorEnabled,
|
|
165
|
-
isRecordingEnabledRef.current
|
|
166
|
-
);
|
|
167
|
-
return client;
|
|
168
|
-
};
|
|
169
|
-
export {
|
|
170
|
-
useNetworkActivityDevTools
|
|
171
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|