@rozenite/network-activity-plugin 1.7.0 → 1.8.1
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 +32 -0
- package/README.md +24 -0
- package/dist/devtools/App.html +2 -2
- package/dist/devtools/assets/{App-pokLiGYV.js → App-B3xlUjs6.js} +163 -115
- package/dist/devtools/assets/{App-BrSkOkws.css → App-m6xge0az.css} +13 -0
- package/dist/react-native/chunks/boot-recording.cjs +307 -28
- package/dist/react-native/chunks/boot-recording.js +310 -31
- package/dist/react-native/chunks/useNetworkActivityDevTools.require.cjs +192 -141
- package/dist/react-native/chunks/useNetworkActivityDevTools.require.js +193 -142
- package/dist/react-native/index.d.ts +24 -7
- package/dist/rozenite.json +1 -1
- package/dist/sdk/index.cjs +127 -0
- package/dist/sdk/index.d.ts +1243 -0
- package/dist/sdk/index.js +127 -0
- package/package.json +17 -6
- package/sdk.ts +59 -0
- package/src/react-native/__tests__/events-listener.test.ts +35 -0
- package/src/react-native/agent/__tests__/network-activity-agent-state.test.ts +21 -9
- package/src/react-native/agent/state.ts +13 -13
- package/src/react-native/agent/tools.ts +20 -146
- package/src/react-native/agent/use-network-activity-agent-tools.ts +73 -64
- package/src/react-native/events-listener.ts +12 -3
- package/src/react-native/http/http-inspector.ts +19 -5
- package/src/react-native/network-inspector.ts +46 -8
- package/src/react-native/nitro-fetch/__tests__/nitro-network-inspector.test.ts +198 -0
- package/src/react-native/nitro-fetch/nitro-network-inspector.ts +403 -0
- package/src/react-native/useHttpInspector.ts +9 -19
- package/src/react-native/useNetworkActivityDevTools.ts +13 -1
- package/src/react-native/websocket/__tests__/websocket-inspector.test.ts +69 -0
- package/src/react-native/websocket/websocket-inspector.ts +32 -17
- package/src/shared/agent-tools.ts +230 -0
- package/src/shared/client.ts +3 -0
- package/src/shared/http-events.ts +6 -0
- package/src/shared/websocket-events.ts +16 -7
- package/src/ui/components/RequestList.tsx +21 -0
- package/src/ui/components/SidePanel.tsx +12 -9
- package/src/ui/state/derived.ts +4 -0
- package/src/ui/state/model.ts +6 -1
- package/src/ui/state/store.ts +52 -36
- package/src/ui/tabs/HeadersTab.tsx +18 -4
- package/src/ui/tabs/ResponseTab.tsx +5 -3
- package/tsconfig.json +4 -1
- package/vite.config.ts +7 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useEffect, useRef } from "react";
|
|
2
2
|
import { useRozeniteDevToolsClient } from "@rozenite/plugin-bridge";
|
|
3
|
-
import { s as safeStringify, g as
|
|
3
|
+
import { s as safeStringify, g as getOverridesRegistry, c as createNetworkInspectorsConfiguration, D as DEFAULT_CONFIG, v as validateConfig, i as isHttpEvent, a as isWebSocketEvent, b as isSSEEvent } from "./boot-recording.js";
|
|
4
4
|
import { useRozenitePluginAgentTool } from "@rozenite/agent-bridge";
|
|
5
|
+
import { defineAgentToolContract } from "@rozenite/agent-shared";
|
|
5
6
|
const DEFAULT_PAGE_LIMIT = 20;
|
|
6
7
|
const MAX_PAGE_LIMIT = 100;
|
|
7
8
|
const HTTP_BUFFER_CAPACITY = 500;
|
|
@@ -621,121 +622,132 @@ const getNetworkActivityAgentState = /* @__PURE__ */ (() => {
|
|
|
621
622
|
return instance;
|
|
622
623
|
};
|
|
623
624
|
})();
|
|
624
|
-
const
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
}
|
|
632
|
-
const stopRecordingTool = {
|
|
633
|
-
name: "stopRecording",
|
|
634
|
-
description: "Stop recording network activity without clearing the captured plugin buffer.",
|
|
635
|
-
inputSchema: {
|
|
636
|
-
type: "object",
|
|
637
|
-
properties: {}
|
|
638
|
-
}
|
|
639
|
-
};
|
|
640
|
-
const getRecordingStatusTool = {
|
|
641
|
-
name: "getRecordingStatus",
|
|
642
|
-
description: "Return network activity plugin recording state and buffer metadata.",
|
|
643
|
-
inputSchema: {
|
|
644
|
-
type: "object",
|
|
645
|
-
properties: {}
|
|
646
|
-
}
|
|
647
|
-
};
|
|
648
|
-
const listRequestsTool = {
|
|
649
|
-
name: "listRequests",
|
|
650
|
-
description: "List captured HTTP request summaries with cursor pagination from the fallback plugin.",
|
|
651
|
-
inputSchema: {
|
|
652
|
-
type: "object",
|
|
653
|
-
properties: {
|
|
654
|
-
limit: {
|
|
655
|
-
type: "number",
|
|
656
|
-
description: "Maximum number of requests to return. Defaults to 20."
|
|
657
|
-
},
|
|
658
|
-
cursor: {
|
|
659
|
-
type: "string",
|
|
660
|
-
description: "Opaque pagination cursor from a previous listRequests call."
|
|
661
|
-
}
|
|
625
|
+
const NETWORK_ACTIVITY_AGENT_PLUGIN_ID = "@rozenite/network-activity-plugin";
|
|
626
|
+
const networkActivityToolDefinitions = {
|
|
627
|
+
startRecording: defineAgentToolContract({
|
|
628
|
+
name: "startRecording",
|
|
629
|
+
description: "Start recording network activity in the fallback network activity plugin.",
|
|
630
|
+
inputSchema: {
|
|
631
|
+
type: "object",
|
|
632
|
+
properties: {}
|
|
662
633
|
}
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
name: "getResponseBody",
|
|
695
|
-
description: "Return the captured response body for a plugin-recorded HTTP request when available.",
|
|
696
|
-
inputSchema: {
|
|
697
|
-
type: "object",
|
|
698
|
-
properties: {
|
|
699
|
-
requestId: {
|
|
700
|
-
type: "string",
|
|
701
|
-
description: "Captured plugin request ID to inspect."
|
|
634
|
+
}),
|
|
635
|
+
stopRecording: defineAgentToolContract({
|
|
636
|
+
name: "stopRecording",
|
|
637
|
+
description: "Stop recording network activity without clearing the captured plugin buffer.",
|
|
638
|
+
inputSchema: {
|
|
639
|
+
type: "object",
|
|
640
|
+
properties: {}
|
|
641
|
+
}
|
|
642
|
+
}),
|
|
643
|
+
getRecordingStatus: defineAgentToolContract({
|
|
644
|
+
name: "getRecordingStatus",
|
|
645
|
+
description: "Return network activity plugin recording state and buffer metadata.",
|
|
646
|
+
inputSchema: {
|
|
647
|
+
type: "object",
|
|
648
|
+
properties: {}
|
|
649
|
+
}
|
|
650
|
+
}),
|
|
651
|
+
listRequests: defineAgentToolContract({
|
|
652
|
+
name: "listRequests",
|
|
653
|
+
description: "List captured HTTP request summaries with cursor pagination from the fallback plugin.",
|
|
654
|
+
inputSchema: {
|
|
655
|
+
type: "object",
|
|
656
|
+
properties: {
|
|
657
|
+
limit: {
|
|
658
|
+
type: "number",
|
|
659
|
+
description: "Maximum number of requests to return. Defaults to 20."
|
|
660
|
+
},
|
|
661
|
+
cursor: {
|
|
662
|
+
type: "string",
|
|
663
|
+
description: "Opaque pagination cursor from a previous listRequests call."
|
|
664
|
+
}
|
|
702
665
|
}
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
description: "Maximum number of realtime connections to return. Defaults to 20."
|
|
666
|
+
}
|
|
667
|
+
}),
|
|
668
|
+
getRequestDetails: defineAgentToolContract({
|
|
669
|
+
name: "getRequestDetails",
|
|
670
|
+
description: "Return detailed metadata for a captured HTTP request without fetching response body.",
|
|
671
|
+
inputSchema: {
|
|
672
|
+
type: "object",
|
|
673
|
+
properties: {
|
|
674
|
+
requestId: {
|
|
675
|
+
type: "string",
|
|
676
|
+
description: "Captured plugin request ID to inspect."
|
|
677
|
+
}
|
|
716
678
|
},
|
|
717
|
-
|
|
718
|
-
type: "string",
|
|
719
|
-
description: "Opaque pagination cursor from a previous listRealtimeConnections call."
|
|
720
|
-
}
|
|
679
|
+
required: ["requestId"]
|
|
721
680
|
}
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
681
|
+
}),
|
|
682
|
+
getRequestBody: defineAgentToolContract({
|
|
683
|
+
name: "getRequestBody",
|
|
684
|
+
description: "Return the captured request body for a plugin-recorded HTTP request when available.",
|
|
685
|
+
inputSchema: {
|
|
686
|
+
type: "object",
|
|
687
|
+
properties: {
|
|
688
|
+
requestId: {
|
|
689
|
+
type: "string",
|
|
690
|
+
description: "Captured plugin request ID to inspect."
|
|
691
|
+
}
|
|
692
|
+
},
|
|
693
|
+
required: ["requestId"]
|
|
694
|
+
}
|
|
695
|
+
}),
|
|
696
|
+
getResponseBody: defineAgentToolContract({
|
|
697
|
+
name: "getResponseBody",
|
|
698
|
+
description: "Return the captured response body for a plugin-recorded HTTP request when available.",
|
|
699
|
+
inputSchema: {
|
|
700
|
+
type: "object",
|
|
701
|
+
properties: {
|
|
702
|
+
requestId: {
|
|
703
|
+
type: "string",
|
|
704
|
+
description: "Captured plugin request ID to inspect."
|
|
705
|
+
}
|
|
706
|
+
},
|
|
707
|
+
required: ["requestId"]
|
|
708
|
+
}
|
|
709
|
+
}),
|
|
710
|
+
listRealtimeConnections: defineAgentToolContract({
|
|
711
|
+
name: "listRealtimeConnections",
|
|
712
|
+
description: "List captured WebSocket and SSE connections with cursor pagination.",
|
|
713
|
+
inputSchema: {
|
|
714
|
+
type: "object",
|
|
715
|
+
properties: {
|
|
716
|
+
limit: {
|
|
717
|
+
type: "number",
|
|
718
|
+
description: "Maximum number of realtime connections to return. Defaults to 20."
|
|
719
|
+
},
|
|
720
|
+
cursor: {
|
|
721
|
+
type: "string",
|
|
722
|
+
description: "Opaque pagination cursor from a previous listRealtimeConnections call."
|
|
723
|
+
}
|
|
733
724
|
}
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
|
|
725
|
+
}
|
|
726
|
+
}),
|
|
727
|
+
getRealtimeConnectionDetails: defineAgentToolContract({
|
|
728
|
+
name: "getRealtimeConnectionDetails",
|
|
729
|
+
description: "Return details for a captured WebSocket or SSE connection, including recent messages.",
|
|
730
|
+
inputSchema: {
|
|
731
|
+
type: "object",
|
|
732
|
+
properties: {
|
|
733
|
+
requestId: {
|
|
734
|
+
type: "string",
|
|
735
|
+
description: "Captured realtime request ID to inspect."
|
|
736
|
+
}
|
|
737
|
+
},
|
|
738
|
+
required: ["requestId"]
|
|
739
|
+
}
|
|
740
|
+
})
|
|
737
741
|
};
|
|
738
|
-
const
|
|
742
|
+
const startRecordingTool = networkActivityToolDefinitions.startRecording;
|
|
743
|
+
const stopRecordingTool = networkActivityToolDefinitions.stopRecording;
|
|
744
|
+
const getRecordingStatusTool = networkActivityToolDefinitions.getRecordingStatus;
|
|
745
|
+
const listRequestsTool = networkActivityToolDefinitions.listRequests;
|
|
746
|
+
const getRequestDetailsTool = networkActivityToolDefinitions.getRequestDetails;
|
|
747
|
+
const getRequestBodyTool = networkActivityToolDefinitions.getRequestBody;
|
|
748
|
+
const getResponseBodyTool = networkActivityToolDefinitions.getResponseBody;
|
|
749
|
+
const listRealtimeConnectionsTool = networkActivityToolDefinitions.listRealtimeConnections;
|
|
750
|
+
const getRealtimeConnectionDetailsTool = networkActivityToolDefinitions.getRealtimeConnectionDetails;
|
|
739
751
|
const useNetworkActivityAgentTools = ({
|
|
740
752
|
client,
|
|
741
753
|
networkInspector,
|
|
@@ -764,6 +776,22 @@ const useNetworkActivityAgentTools = ({
|
|
|
764
776
|
"request-failed",
|
|
765
777
|
(event) => state.onRequestFailed(event)
|
|
766
778
|
),
|
|
779
|
+
networkInspector.nitro.on(
|
|
780
|
+
"request-sent",
|
|
781
|
+
(event) => state.onRequestSent(event)
|
|
782
|
+
),
|
|
783
|
+
networkInspector.nitro.on(
|
|
784
|
+
"response-received",
|
|
785
|
+
(event) => state.onResponseReceived(event)
|
|
786
|
+
),
|
|
787
|
+
networkInspector.nitro.on(
|
|
788
|
+
"request-completed",
|
|
789
|
+
(event) => state.onRequestCompleted(event)
|
|
790
|
+
),
|
|
791
|
+
networkInspector.nitro.on(
|
|
792
|
+
"request-failed",
|
|
793
|
+
(event) => state.onRequestFailed(event)
|
|
794
|
+
),
|
|
767
795
|
networkInspector.websocket.on(
|
|
768
796
|
"websocket-connect",
|
|
769
797
|
(event) => state.onWebSocketConnect(event)
|
|
@@ -792,8 +820,35 @@ const useNetworkActivityAgentTools = ({
|
|
|
792
820
|
"websocket-connection-status-changed",
|
|
793
821
|
(event) => state.onWebSocketConnectionStatusChanged(event)
|
|
794
822
|
),
|
|
823
|
+
networkInspector.nitro.on(
|
|
824
|
+
"websocket-connect",
|
|
825
|
+
(event) => state.onWebSocketConnect(event)
|
|
826
|
+
),
|
|
827
|
+
networkInspector.nitro.on(
|
|
828
|
+
"websocket-open",
|
|
829
|
+
(event) => state.onWebSocketOpen(event)
|
|
830
|
+
),
|
|
831
|
+
networkInspector.nitro.on(
|
|
832
|
+
"websocket-close",
|
|
833
|
+
(event) => state.onWebSocketClose(event)
|
|
834
|
+
),
|
|
835
|
+
networkInspector.nitro.on(
|
|
836
|
+
"websocket-message-sent",
|
|
837
|
+
(event) => state.onWebSocketMessageSent(event)
|
|
838
|
+
),
|
|
839
|
+
networkInspector.nitro.on(
|
|
840
|
+
"websocket-message-received",
|
|
841
|
+
(event) => state.onWebSocketMessageReceived(event)
|
|
842
|
+
),
|
|
843
|
+
networkInspector.nitro.on(
|
|
844
|
+
"websocket-error",
|
|
845
|
+
(event) => state.onWebSocketError(event)
|
|
846
|
+
),
|
|
795
847
|
networkInspector.sse.on("sse-open", (event) => state.onSSEOpen(event)),
|
|
796
|
-
networkInspector.sse.on(
|
|
848
|
+
networkInspector.sse.on(
|
|
849
|
+
"sse-message",
|
|
850
|
+
(event) => state.onSSEMessage(event)
|
|
851
|
+
),
|
|
797
852
|
networkInspector.sse.on("sse-error", (event) => state.onSSEError(event)),
|
|
798
853
|
networkInspector.sse.on("sse-close", (event) => state.onSSEClose(event))
|
|
799
854
|
];
|
|
@@ -820,7 +875,7 @@ const useNetworkActivityAgentTools = ({
|
|
|
820
875
|
};
|
|
821
876
|
}, [client, enabledInspectors, state]);
|
|
822
877
|
useRozenitePluginAgentTool({
|
|
823
|
-
pluginId,
|
|
878
|
+
pluginId: NETWORK_ACTIVITY_AGENT_PLUGIN_ID,
|
|
824
879
|
tool: startRecordingTool,
|
|
825
880
|
handler: () => {
|
|
826
881
|
networkInspector.http.getNetworkRequestsRegistry().clear();
|
|
@@ -833,7 +888,7 @@ const useNetworkActivityAgentTools = ({
|
|
|
833
888
|
}
|
|
834
889
|
});
|
|
835
890
|
useRozenitePluginAgentTool({
|
|
836
|
-
pluginId,
|
|
891
|
+
pluginId: NETWORK_ACTIVITY_AGENT_PLUGIN_ID,
|
|
837
892
|
tool: stopRecordingTool,
|
|
838
893
|
handler: () => {
|
|
839
894
|
const result = state.stopRecording();
|
|
@@ -845,27 +900,27 @@ const useNetworkActivityAgentTools = ({
|
|
|
845
900
|
}
|
|
846
901
|
});
|
|
847
902
|
useRozenitePluginAgentTool({
|
|
848
|
-
pluginId,
|
|
903
|
+
pluginId: NETWORK_ACTIVITY_AGENT_PLUGIN_ID,
|
|
849
904
|
tool: getRecordingStatusTool,
|
|
850
905
|
handler: () => state.getStatus()
|
|
851
906
|
});
|
|
852
907
|
useRozenitePluginAgentTool({
|
|
853
|
-
pluginId,
|
|
908
|
+
pluginId: NETWORK_ACTIVITY_AGENT_PLUGIN_ID,
|
|
854
909
|
tool: listRequestsTool,
|
|
855
910
|
handler: (input = {}) => state.listRequests(input)
|
|
856
911
|
});
|
|
857
912
|
useRozenitePluginAgentTool({
|
|
858
|
-
pluginId,
|
|
913
|
+
pluginId: NETWORK_ACTIVITY_AGENT_PLUGIN_ID,
|
|
859
914
|
tool: getRequestDetailsTool,
|
|
860
915
|
handler: ({ requestId }) => state.getRequestDetails(requestId)
|
|
861
916
|
});
|
|
862
917
|
useRozenitePluginAgentTool({
|
|
863
|
-
pluginId,
|
|
918
|
+
pluginId: NETWORK_ACTIVITY_AGENT_PLUGIN_ID,
|
|
864
919
|
tool: getRequestBodyTool,
|
|
865
920
|
handler: ({ requestId }) => state.getRequestBody(requestId)
|
|
866
921
|
});
|
|
867
922
|
useRozenitePluginAgentTool({
|
|
868
|
-
pluginId,
|
|
923
|
+
pluginId: NETWORK_ACTIVITY_AGENT_PLUGIN_ID,
|
|
869
924
|
tool: getResponseBodyTool,
|
|
870
925
|
handler: async ({ requestId }) => {
|
|
871
926
|
const record = state.getHttpRecord(requestId);
|
|
@@ -886,15 +941,7 @@ const useNetworkActivityAgentTools = ({
|
|
|
886
941
|
reason: "Response body is unavailable until the request finishes loading."
|
|
887
942
|
};
|
|
888
943
|
}
|
|
889
|
-
const
|
|
890
|
-
if (!request) {
|
|
891
|
-
return {
|
|
892
|
-
requestId,
|
|
893
|
-
available: false,
|
|
894
|
-
reason: "Response body is unavailable because the request object is no longer in the plugin registry."
|
|
895
|
-
};
|
|
896
|
-
}
|
|
897
|
-
const body = await getResponseBody(request);
|
|
944
|
+
const body = await networkInspector.getResponseBody(requestId);
|
|
898
945
|
if (body === null) {
|
|
899
946
|
return {
|
|
900
947
|
requestId,
|
|
@@ -913,39 +960,34 @@ const useNetworkActivityAgentTools = ({
|
|
|
913
960
|
}
|
|
914
961
|
});
|
|
915
962
|
useRozenitePluginAgentTool({
|
|
916
|
-
pluginId,
|
|
963
|
+
pluginId: NETWORK_ACTIVITY_AGENT_PLUGIN_ID,
|
|
917
964
|
tool: listRealtimeConnectionsTool,
|
|
918
965
|
handler: (input = {}) => state.listRealtimeConnections(input)
|
|
919
966
|
});
|
|
920
967
|
useRozenitePluginAgentTool({
|
|
921
|
-
pluginId,
|
|
968
|
+
pluginId: NETWORK_ACTIVITY_AGENT_PLUGIN_ID,
|
|
922
969
|
tool: getRealtimeConnectionDetailsTool,
|
|
923
970
|
handler: ({ requestId }) => state.getRealtimeConnectionDetails(requestId)
|
|
924
971
|
});
|
|
925
972
|
};
|
|
926
973
|
const overridesRegistry = getOverridesRegistry();
|
|
927
|
-
const useHttpInspector = (client,
|
|
974
|
+
const useHttpInspector = (client, networkInspector, isEnabled, isRecordingEnabled) => {
|
|
928
975
|
useEffect(() => {
|
|
929
976
|
if (!client || !isEnabled) {
|
|
930
977
|
return;
|
|
931
978
|
}
|
|
932
|
-
const networkRequestsRegistry = httpInspector.getNetworkRequestsRegistry();
|
|
933
979
|
const subscriptions = [
|
|
934
980
|
client.onMessage("network-enable", () => {
|
|
935
|
-
|
|
981
|
+
networkInspector.http.enable();
|
|
936
982
|
}),
|
|
937
983
|
client.onMessage("network-disable", () => {
|
|
938
|
-
|
|
984
|
+
networkInspector.http.disable();
|
|
939
985
|
}),
|
|
940
986
|
client.onMessage("set-overrides", (data) => {
|
|
941
987
|
overridesRegistry.setOverrides(data.overrides);
|
|
942
988
|
}),
|
|
943
989
|
client.onMessage("get-response-body", async ({ requestId }) => {
|
|
944
|
-
const
|
|
945
|
-
if (!request) {
|
|
946
|
-
return;
|
|
947
|
-
}
|
|
948
|
-
const body = await getResponseBody(request);
|
|
990
|
+
const body = await networkInspector.getResponseBody(requestId);
|
|
949
991
|
client.send("response-body", {
|
|
950
992
|
requestId,
|
|
951
993
|
body
|
|
@@ -953,13 +995,13 @@ const useHttpInspector = (client, httpInspector, isEnabled, isRecordingEnabled)
|
|
|
953
995
|
})
|
|
954
996
|
];
|
|
955
997
|
if (isRecordingEnabled) {
|
|
956
|
-
|
|
998
|
+
networkInspector.http.enable();
|
|
957
999
|
}
|
|
958
1000
|
return () => {
|
|
959
1001
|
subscriptions.forEach((subscription) => subscription.remove());
|
|
960
|
-
|
|
1002
|
+
networkInspector.http.dispose();
|
|
961
1003
|
};
|
|
962
|
-
}, [client,
|
|
1004
|
+
}, [client, networkInspector, isEnabled, isRecordingEnabled]);
|
|
963
1005
|
};
|
|
964
1006
|
const useWebSocketInspector = (client, websocketInspector, isEnabled, isRecordingEnabled) => {
|
|
965
1007
|
useEffect(() => {
|
|
@@ -1045,6 +1087,11 @@ const useNetworkActivityDevTools = (config = DEFAULT_CONFIG) => {
|
|
|
1045
1087
|
const subscriptions = [
|
|
1046
1088
|
client.onMessage("network-enable", () => {
|
|
1047
1089
|
isRecordingEnabledRef.current = true;
|
|
1090
|
+
networkInspector.enable({
|
|
1091
|
+
http: isHttpInspectorEnabled,
|
|
1092
|
+
websocket: isWebSocketInspectorEnabled,
|
|
1093
|
+
sse: isSSEInspectorEnabled
|
|
1094
|
+
});
|
|
1048
1095
|
eventsListener.connect(client.send, (message) => {
|
|
1049
1096
|
const type = message.type;
|
|
1050
1097
|
if (isHttpEvent(type)) {
|
|
@@ -1061,11 +1108,15 @@ const useNetworkActivityDevTools = (config = DEFAULT_CONFIG) => {
|
|
|
1061
1108
|
}),
|
|
1062
1109
|
client.onMessage("network-disable", () => {
|
|
1063
1110
|
isRecordingEnabledRef.current = false;
|
|
1111
|
+
networkInspector.disable();
|
|
1064
1112
|
}),
|
|
1065
1113
|
client.onMessage("get-client-ui-settings", () => {
|
|
1066
1114
|
sendClientUISettings();
|
|
1067
1115
|
})
|
|
1068
1116
|
];
|
|
1117
|
+
client.send("recording-state", {
|
|
1118
|
+
isRecording: isRecordingEnabledRef.current
|
|
1119
|
+
});
|
|
1069
1120
|
sendClientUISettings();
|
|
1070
1121
|
return () => {
|
|
1071
1122
|
subscriptions.forEach((subscription) => subscription.remove());
|
|
@@ -1079,7 +1130,7 @@ const useNetworkActivityDevTools = (config = DEFAULT_CONFIG) => {
|
|
|
1079
1130
|
]);
|
|
1080
1131
|
useHttpInspector(
|
|
1081
1132
|
client,
|
|
1082
|
-
networkInspector
|
|
1133
|
+
networkInspector,
|
|
1083
1134
|
isHttpInspectorEnabled,
|
|
1084
1135
|
isRecordingEnabledRef.current
|
|
1085
1136
|
);
|
|
@@ -25,12 +25,14 @@ declare type HttpEventMap = {
|
|
|
25
25
|
timestamp: Timestamp;
|
|
26
26
|
initiator: Initiator;
|
|
27
27
|
type: ResourceType;
|
|
28
|
+
source?: NetworkEventSource;
|
|
28
29
|
};
|
|
29
30
|
'response-received': {
|
|
30
31
|
requestId: RequestId;
|
|
31
32
|
timestamp: Timestamp;
|
|
32
33
|
type: ResourceType;
|
|
33
34
|
response: Response_2;
|
|
35
|
+
source?: NetworkEventSource;
|
|
34
36
|
};
|
|
35
37
|
'request-completed': {
|
|
36
38
|
requestId: RequestId;
|
|
@@ -38,6 +40,7 @@ declare type HttpEventMap = {
|
|
|
38
40
|
duration: number;
|
|
39
41
|
size: number | null;
|
|
40
42
|
ttfb: number;
|
|
43
|
+
source?: NetworkEventSource;
|
|
41
44
|
};
|
|
42
45
|
'request-failed': {
|
|
43
46
|
requestId: RequestId;
|
|
@@ -45,6 +48,7 @@ declare type HttpEventMap = {
|
|
|
45
48
|
type: ResourceType;
|
|
46
49
|
error: string;
|
|
47
50
|
canceled: boolean;
|
|
51
|
+
source?: NetworkEventSource;
|
|
48
52
|
};
|
|
49
53
|
'request-progress': {
|
|
50
54
|
requestId: RequestId;
|
|
@@ -52,6 +56,7 @@ declare type HttpEventMap = {
|
|
|
52
56
|
loaded: number;
|
|
53
57
|
total: number;
|
|
54
58
|
lengthComputable: boolean;
|
|
59
|
+
source?: NetworkEventSource;
|
|
55
60
|
};
|
|
56
61
|
'get-response-body': {
|
|
57
62
|
requestId: RequestId;
|
|
@@ -99,12 +104,17 @@ export declare type NetworkActivityDevToolsConfig = NetworkInspectorConfig & {
|
|
|
99
104
|
declare type NetworkActivityEventMap = {
|
|
100
105
|
'network-enable': unknown;
|
|
101
106
|
'network-disable': unknown;
|
|
107
|
+
'recording-state': {
|
|
108
|
+
isRecording: boolean;
|
|
109
|
+
};
|
|
102
110
|
'get-client-ui-settings': unknown;
|
|
103
111
|
'client-ui-settings': {
|
|
104
112
|
settings?: NetworkActivityClientUISettings;
|
|
105
113
|
};
|
|
106
114
|
} & HttpEventMap & WebSocketEventMap_2 & SSEEventMap;
|
|
107
115
|
|
|
116
|
+
declare type NetworkEventSource = 'builtin' | 'nitro';
|
|
117
|
+
|
|
108
118
|
declare type NetworkInspectorConfig = {
|
|
109
119
|
/**
|
|
110
120
|
* Specifies which network inspectors are enabled.
|
|
@@ -213,19 +223,21 @@ declare const useNetworkActivityDevTools_2: (config?: NetworkActivityDevToolsCon
|
|
|
213
223
|
declare type WebSocketCloseEvent = {
|
|
214
224
|
type: 'websocket-close';
|
|
215
225
|
url: string;
|
|
216
|
-
socketId:
|
|
226
|
+
socketId: string;
|
|
217
227
|
timestamp: number;
|
|
218
228
|
code: number;
|
|
219
229
|
reason?: string;
|
|
230
|
+
source?: NetworkEventSource;
|
|
220
231
|
};
|
|
221
232
|
|
|
222
233
|
declare type WebSocketConnectEvent = {
|
|
223
234
|
type: 'websocket-connect';
|
|
224
235
|
url: string;
|
|
225
|
-
socketId:
|
|
236
|
+
socketId: string;
|
|
226
237
|
timestamp: number;
|
|
227
238
|
protocols: string[] | null;
|
|
228
239
|
options: string[];
|
|
240
|
+
source?: NetworkEventSource;
|
|
229
241
|
};
|
|
230
242
|
|
|
231
243
|
declare type WebSocketConnectionStatus = 'connecting' | 'open' | 'closing' | 'closed';
|
|
@@ -233,17 +245,19 @@ declare type WebSocketConnectionStatus = 'connecting' | 'open' | 'closing' | 'cl
|
|
|
233
245
|
declare type WebSocketConnectionStatusChangedEvent = {
|
|
234
246
|
type: 'websocket-connection-status-changed';
|
|
235
247
|
url: string;
|
|
236
|
-
socketId:
|
|
248
|
+
socketId: string;
|
|
237
249
|
timestamp: number;
|
|
238
250
|
status: WebSocketConnectionStatus;
|
|
251
|
+
source?: NetworkEventSource;
|
|
239
252
|
};
|
|
240
253
|
|
|
241
254
|
declare type WebSocketErrorEvent = {
|
|
242
255
|
type: 'websocket-error';
|
|
243
256
|
url: string;
|
|
244
|
-
socketId:
|
|
257
|
+
socketId: string;
|
|
245
258
|
timestamp: number;
|
|
246
259
|
error: string;
|
|
260
|
+
source?: NetworkEventSource;
|
|
247
261
|
};
|
|
248
262
|
|
|
249
263
|
declare type WebSocketEvent = WebSocketConnectEvent | WebSocketOpenEvent | WebSocketCloseEvent | WebSocketMessageSentEvent | WebSocketMessageReceivedEvent | WebSocketErrorEvent | WebSocketConnectionStatusChangedEvent;
|
|
@@ -257,19 +271,21 @@ declare type WebSocketEventMap_2 = {
|
|
|
257
271
|
declare type WebSocketMessageReceivedEvent = {
|
|
258
272
|
type: 'websocket-message-received';
|
|
259
273
|
url: string;
|
|
260
|
-
socketId:
|
|
274
|
+
socketId: string;
|
|
261
275
|
timestamp: number;
|
|
262
276
|
data: string;
|
|
263
277
|
messageType: WebSocketMessageType;
|
|
278
|
+
source?: NetworkEventSource;
|
|
264
279
|
};
|
|
265
280
|
|
|
266
281
|
declare type WebSocketMessageSentEvent = {
|
|
267
282
|
type: 'websocket-message-sent';
|
|
268
283
|
url: string;
|
|
269
|
-
socketId:
|
|
284
|
+
socketId: string;
|
|
270
285
|
timestamp: number;
|
|
271
286
|
data: string;
|
|
272
287
|
messageType: WebSocketMessageType;
|
|
288
|
+
source?: NetworkEventSource;
|
|
273
289
|
};
|
|
274
290
|
|
|
275
291
|
declare type WebSocketMessageType = 'text' | 'binary';
|
|
@@ -277,8 +293,9 @@ declare type WebSocketMessageType = 'text' | 'binary';
|
|
|
277
293
|
declare type WebSocketOpenEvent = {
|
|
278
294
|
type: 'websocket-open';
|
|
279
295
|
url: string;
|
|
280
|
-
socketId:
|
|
296
|
+
socketId: string;
|
|
281
297
|
timestamp: number;
|
|
298
|
+
source?: NetworkEventSource;
|
|
282
299
|
};
|
|
283
300
|
|
|
284
301
|
export declare let withOnBootNetworkActivityRecording: withOnBootNetworkActivityRecording_2;
|
package/dist/rozenite.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@rozenite/network-activity-plugin","version":"1.
|
|
1
|
+
{"name":"@rozenite/network-activity-plugin","version":"1.8.1","description":"Network Activity for Rozenite.","panels":[{"name":"Network Activity","source":"/devtools/App.html"}]}
|