@rozenite/network-activity-plugin 1.9.0 → 1.11.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.
Files changed (84) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/dist/devtools/App.html +2 -2
  3. package/dist/devtools/assets/{App-hSoryVpJ.js → App-CEESZAW_.js} +7520 -937
  4. package/dist/devtools/assets/{App-m6xge0az.css → App-xppYUJvX.css} +246 -2
  5. package/dist/react-native/chunks/boot-recording.cjs +138 -14
  6. package/dist/react-native/chunks/boot-recording.js +138 -14
  7. package/dist/react-native/chunks/get-nitro-module.cjs +4 -1
  8. package/dist/react-native/chunks/get-nitro-module.js +4 -1
  9. package/dist/react-native/chunks/useNetworkActivityDevTools.require.cjs +20 -1
  10. package/dist/react-native/chunks/useNetworkActivityDevTools.require.js +20 -1
  11. package/dist/react-native/index.d.ts +37 -1
  12. package/dist/rozenite.json +1 -1
  13. package/dist/sdk/index.d.ts +37 -1
  14. package/package.json +12 -7
  15. package/src/react-native/agent/use-network-activity-agent-tools.ts +22 -4
  16. package/src/react-native/http/__tests__/http-utils.test.ts +228 -0
  17. package/src/react-native/http/http-utils.ts +208 -25
  18. package/src/react-native/network-inspector.ts +2 -2
  19. package/src/react-native/nitro-fetch/get-nitro-module.ts +5 -1
  20. package/src/react-native/nitro-fetch/nitro-network-inspector.ts +8 -2
  21. package/src/shared/http-events.ts +40 -1
  22. package/src/ui/components/CodeBlock.tsx +45 -1
  23. package/src/ui/components/FilterBar.tsx +337 -61
  24. package/src/ui/components/HexView.tsx +54 -0
  25. package/src/ui/components/MetadataCard.tsx +95 -0
  26. package/src/ui/components/NetworkTimeline.tsx +422 -0
  27. package/src/ui/components/RequestList.tsx +19 -40
  28. package/src/ui/components/SidePanel.tsx +42 -1
  29. package/src/ui/components/Toolbar.tsx +13 -1
  30. package/src/ui/components/ViewToggle.tsx +44 -0
  31. package/src/ui/components/XmlTree.tsx +160 -0
  32. package/src/ui/components/__tests__/CodeBlock.test.tsx +89 -0
  33. package/src/ui/components/__tests__/HexView.test.tsx +41 -0
  34. package/src/ui/components/__tests__/MetadataCard.test.tsx +107 -0
  35. package/src/ui/components/__tests__/ViewToggle.test.tsx +80 -0
  36. package/src/ui/components/__tests__/XmlTree.test.tsx +149 -0
  37. package/src/ui/hooks/useNetworkActivitySessionExport.ts +39 -0
  38. package/src/ui/response-renderers/__tests__/binary-too-large.test.tsx +56 -0
  39. package/src/ui/response-renderers/__tests__/binary.test.tsx +96 -0
  40. package/src/ui/response-renderers/__tests__/dispatch.test.ts +124 -0
  41. package/src/ui/response-renderers/__tests__/html.test.tsx +101 -0
  42. package/src/ui/response-renderers/__tests__/image.test.tsx +73 -0
  43. package/src/ui/response-renderers/__tests__/json.test.tsx +95 -0
  44. package/src/ui/response-renderers/__tests__/svg.test.tsx +46 -0
  45. package/src/ui/response-renderers/__tests__/xml.test.tsx +100 -0
  46. package/src/ui/response-renderers/binary-too-large.tsx +36 -0
  47. package/src/ui/response-renderers/binary.tsx +31 -0
  48. package/src/ui/response-renderers/empty.tsx +14 -0
  49. package/src/ui/response-renderers/html.tsx +36 -0
  50. package/src/ui/response-renderers/image.tsx +37 -0
  51. package/src/ui/response-renderers/index.ts +55 -0
  52. package/src/ui/response-renderers/json.tsx +40 -0
  53. package/src/ui/response-renderers/svg.tsx +27 -0
  54. package/src/ui/response-renderers/text-fallback.tsx +14 -0
  55. package/src/ui/response-renderers/types.ts +38 -0
  56. package/src/ui/response-renderers/unknown.tsx +18 -0
  57. package/src/ui/response-renderers/xml.tsx +46 -0
  58. package/src/ui/state/__tests__/store.test.ts +77 -0
  59. package/src/ui/state/derived.ts +14 -0
  60. package/src/ui/state/filter.ts +49 -0
  61. package/src/ui/state/hooks.ts +2 -2
  62. package/src/ui/state/model.ts +7 -1
  63. package/src/ui/state/store.ts +63 -4
  64. package/src/ui/tabs/InitiatorTab.tsx +230 -0
  65. package/src/ui/tabs/ResponseTab.tsx +80 -97
  66. package/src/ui/tabs/__tests__/ResponseTab.test.tsx +102 -0
  67. package/src/ui/utils/__tests__/download.test.ts +115 -0
  68. package/src/ui/utils/__tests__/hex.test.ts +84 -0
  69. package/src/ui/utils/__tests__/requestFilters.test.ts +32 -0
  70. package/src/ui/utils/__tests__/sessionExport.test.ts +174 -0
  71. package/src/ui/utils/__tests__/symbolication.test.ts +207 -0
  72. package/src/ui/utils/__tests__/timelineModel.test.ts +170 -0
  73. package/src/ui/utils/download.ts +161 -0
  74. package/src/ui/utils/hex.ts +59 -0
  75. package/src/ui/utils/initiator.ts +136 -0
  76. package/src/ui/utils/requestFilters.ts +183 -0
  77. package/src/ui/utils/sessionExport.ts +185 -0
  78. package/src/ui/utils/symbolication.ts +248 -0
  79. package/src/ui/utils/timelineModel.ts +352 -0
  80. package/src/ui/views/InspectorView.tsx +43 -8
  81. package/src/utils/__tests__/getContentTypeMimeType.test.ts +34 -0
  82. package/src/utils/getContentTypeMimeType.ts +14 -0
  83. package/vite.config.ts +5 -1
  84. package/vitest.setup.ts +31 -0
@@ -2,6 +2,7 @@ import { describe, expect, it } from 'vitest';
2
2
  import {
3
3
  getContentTypeMime,
4
4
  isJsonContentType,
5
+ isXmlContentType,
5
6
  } from '../getContentTypeMimeType';
6
7
 
7
8
  describe('getContentTypeMimeType', () => {
@@ -28,4 +29,37 @@ describe('getContentTypeMimeType', () => {
28
29
  }),
29
30
  ).toBe('Application/LD+JSON');
30
31
  });
32
+
33
+ it('recognizes application/xml and text/xml with parameters', () => {
34
+ expect(isXmlContentType('application/xml')).toBe(true);
35
+ expect(isXmlContentType('application/xml; charset=utf-8')).toBe(true);
36
+ expect(isXmlContentType('text/xml')).toBe(true);
37
+ expect(isXmlContentType('text/xml; charset=utf-8')).toBe(true);
38
+ });
39
+
40
+ it('recognizes RFC 7303 +xml content types (Atom, RSS, SOAP, XHTML, SVG, ...)', () => {
41
+ expect(isXmlContentType('application/atom+xml')).toBe(true);
42
+ expect(isXmlContentType('application/rss+xml')).toBe(true);
43
+ expect(isXmlContentType('application/soap+xml; charset=utf-8')).toBe(true);
44
+ expect(isXmlContentType('application/xhtml+xml')).toBe(true);
45
+ // SVG is XML by structure — the predicate matches it. The registry
46
+ // gives svgRenderer an earlier slot so it claims SVG first; that
47
+ // ordering is verified separately in dispatch.test.ts.
48
+ expect(isXmlContentType('image/svg+xml')).toBe(true);
49
+ });
50
+
51
+ it('is case-insensitive (normalizeContentType lowercases)', () => {
52
+ expect(isXmlContentType('Application/XML')).toBe(true);
53
+ expect(isXmlContentType('Application/Atom+XML')).toBe(true);
54
+ });
55
+
56
+ it('rejects non-xml content types', () => {
57
+ expect(isXmlContentType('text/plain')).toBe(false);
58
+ expect(isXmlContentType('text/html')).toBe(false);
59
+ expect(isXmlContentType('application/json')).toBe(false);
60
+ expect(isXmlContentType('application/xmlfoo')).toBe(false);
61
+ expect(isXmlContentType(undefined)).toBe(false);
62
+ expect(isXmlContentType(null)).toBe(false);
63
+ expect(isXmlContentType('')).toBe(false);
64
+ });
31
65
  });
@@ -29,3 +29,17 @@ export function isJsonContentType(contentType: string | null | undefined) {
29
29
 
30
30
  return mimeType === 'application/json' || mimeType.endsWith('+json');
31
31
  }
32
+
33
+ export function isXmlContentType(contentType: string | null | undefined) {
34
+ if (!contentType) {
35
+ return false;
36
+ }
37
+
38
+ const mimeType = normalizeContentType(contentType);
39
+
40
+ return (
41
+ mimeType === 'application/xml' ||
42
+ mimeType === 'text/xml' ||
43
+ mimeType.endsWith('+xml')
44
+ );
45
+ }
package/vite.config.ts CHANGED
@@ -8,8 +8,12 @@ export default defineConfig({
8
8
  plugins: [rozenitePlugin()],
9
9
  test: {
10
10
  passWithNoTests: true,
11
+ setupFiles: ['./vitest.setup.ts'],
11
12
  alias: {
12
- '@rozenite/agent-shared': resolve(__dirname, '../agent-shared/src/index.ts'),
13
+ '@rozenite/agent-shared': resolve(
14
+ __dirname,
15
+ '../agent-shared/src/index.ts',
16
+ ),
13
17
  },
14
18
  },
15
19
  base: './',
@@ -0,0 +1,31 @@
1
+ import * as React from 'react';
2
+ import { afterEach, vi } from 'vitest';
3
+ import { cleanup } from '@testing-library/react';
4
+ import '@testing-library/jest-dom/vitest';
5
+
6
+ afterEach(() => {
7
+ cleanup();
8
+ });
9
+
10
+ // `react-virtuoso` doesn't render rows in jsdom — the underlying
11
+ // element-resize observation never fires without a real browser
12
+ // layout. Replace it with a non-virtualized passthrough so RTL tests
13
+ // can assert on the actual row content. Production code is unaffected.
14
+ vi.mock('react-virtuoso', () => ({
15
+ Virtuoso: ({
16
+ totalCount,
17
+ itemContent,
18
+ className,
19
+ }: {
20
+ totalCount: number;
21
+ itemContent: (index: number) => React.ReactNode;
22
+ className?: string;
23
+ }) =>
24
+ React.createElement(
25
+ 'div',
26
+ { 'data-testid': 'virtuoso-mock', className },
27
+ ...Array.from({ length: totalCount }, (_, i) =>
28
+ React.createElement('div', { key: i }, itemContent(i)),
29
+ ),
30
+ ),
31
+ }));