@rozenite/network-activity-plugin 1.0.0-alpha.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/LICENSE +20 -0
- package/README.md +73 -0
- package/dist/assets/panel-C5YgUUj5.js +54 -0
- package/dist/assets/panel-NCVczPb1.css +1 -0
- package/dist/panel.html +31 -0
- package/dist/react-native.cjs +1 -0
- package/dist/react-native.d.ts +5 -0
- package/dist/react-native.js +174 -0
- package/dist/rozenite.json +1 -0
- package/package.json +31 -0
- package/react-native.ts +7 -0
- package/rozenite.config.ts +8 -0
- package/src/css-modules.d.ts +4 -0
- package/src/react-native/useNetworkActivityDevTools.ts +235 -0
- package/src/types/network.ts +153 -0
- package/src/ui/components.module.css +158 -0
- package/src/ui/components.tsx +219 -0
- package/src/ui/network-details.module.css +57 -0
- package/src/ui/network-details.tsx +134 -0
- package/src/ui/network-list.module.css +122 -0
- package/src/ui/network-list.tsx +145 -0
- package/src/ui/network-toolbar.module.css +9 -0
- package/src/ui/network-toolbar.tsx +40 -0
- package/src/ui/panel.module.css +61 -0
- package/src/ui/panel.tsx +201 -0
- package/src/ui/tanstack-query.tsx +197 -0
- package/src/ui/utils.ts +89 -0
- package/tsconfig.json +25 -0
- package/vite.config.ts +20 -0
package/src/ui/utils.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// Utility functions for formatting and styling
|
|
2
|
+
|
|
3
|
+
export const formatTime = (timestamp: number): string => {
|
|
4
|
+
const date = new Date(timestamp * 1000);
|
|
5
|
+
return date.toLocaleTimeString();
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const formatDuration = (duration: number): string => {
|
|
9
|
+
if (duration < 1000) return `${Math.round(duration)}ms`;
|
|
10
|
+
return `${(duration / 1000).toFixed(2)}s`;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const getStatusColor = (status: number): string => {
|
|
14
|
+
if (status >= 200 && status < 300) return '#4caf50';
|
|
15
|
+
if (status >= 300 && status < 400) return '#ff9800';
|
|
16
|
+
if (status >= 400 && status < 500) return '#f44336';
|
|
17
|
+
if (status >= 500) return '#9c27b0';
|
|
18
|
+
return '#757575';
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const getMethodColor = (method: string): string => {
|
|
22
|
+
switch (method.toUpperCase()) {
|
|
23
|
+
case 'GET': return '#61affe';
|
|
24
|
+
case 'POST': return '#49cc90';
|
|
25
|
+
case 'PUT': return '#fca130';
|
|
26
|
+
case 'DELETE': return '#f93e3e';
|
|
27
|
+
case 'PATCH': return '#50e3c2';
|
|
28
|
+
default: return '#757575';
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const formatFileSize = (bytes: number): string => {
|
|
33
|
+
if (bytes === 0) return '0 B';
|
|
34
|
+
const k = 1024;
|
|
35
|
+
const sizes = ['B', 'KB', 'MB', 'GB'];
|
|
36
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
37
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + ' ' + sizes[i];
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const parseUrl = (url: string) => {
|
|
41
|
+
try {
|
|
42
|
+
const urlObj = new URL(url);
|
|
43
|
+
return {
|
|
44
|
+
domain: urlObj.hostname,
|
|
45
|
+
path: urlObj.pathname + urlObj.search,
|
|
46
|
+
protocol: urlObj.protocol,
|
|
47
|
+
};
|
|
48
|
+
} catch {
|
|
49
|
+
return {
|
|
50
|
+
domain: 'Invalid URL',
|
|
51
|
+
path: url,
|
|
52
|
+
protocol: 'unknown',
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const truncateText = (text: string, maxLength: number): string => {
|
|
58
|
+
if (text.length <= maxLength) return text;
|
|
59
|
+
return text.substring(0, maxLength) + '...';
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const formatLongUrl = (url: string, maxLength = 80): string => {
|
|
63
|
+
if (url.length <= maxLength) return url;
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
const urlObj = new URL(url);
|
|
67
|
+
const protocol = urlObj.protocol;
|
|
68
|
+
const hostname = urlObj.hostname;
|
|
69
|
+
const pathname = urlObj.pathname;
|
|
70
|
+
const search = urlObj.search;
|
|
71
|
+
|
|
72
|
+
// Keep protocol and hostname, truncate path if needed
|
|
73
|
+
const baseLength = protocol.length + hostname.length + 3; // +3 for "://"
|
|
74
|
+
const remainingLength = maxLength - baseLength - 3; // -3 for "..."
|
|
75
|
+
|
|
76
|
+
if (remainingLength <= 0) {
|
|
77
|
+
return `${protocol}//${hostname}...`;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const fullPath = pathname + search;
|
|
81
|
+
if (fullPath.length <= remainingLength) {
|
|
82
|
+
return url;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return `${protocol}//${hostname}${fullPath.substring(0, remainingLength)}...`;
|
|
86
|
+
} catch {
|
|
87
|
+
return truncateText(url, maxLength);
|
|
88
|
+
}
|
|
89
|
+
};
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
5
|
+
"allowJs": true,
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"allowSyntheticDefaultImports": true,
|
|
9
|
+
"strict": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"noFallthroughCasesInSwitch": true,
|
|
12
|
+
"module": "ESNext",
|
|
13
|
+
"moduleResolution": "bundler",
|
|
14
|
+
"resolveJsonModule": true,
|
|
15
|
+
"isolatedModules": true,
|
|
16
|
+
"noEmit": true,
|
|
17
|
+
"jsx": "react-jsx"
|
|
18
|
+
},
|
|
19
|
+
"include": [
|
|
20
|
+
"src/**/*",
|
|
21
|
+
"react-native.ts",
|
|
22
|
+
"rozenite.config.ts"
|
|
23
|
+
],
|
|
24
|
+
"exclude": ["node_modules", "dist", "build"]
|
|
25
|
+
}
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types='vitest' />
|
|
2
|
+
import { defineConfig } from 'vite';
|
|
3
|
+
import { rozenitePlugin } from '@rozenite/vite-plugin';
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
root: __dirname,
|
|
7
|
+
plugins: [rozenitePlugin()],
|
|
8
|
+
base: './',
|
|
9
|
+
build: {
|
|
10
|
+
outDir: './dist',
|
|
11
|
+
emptyOutDir: false,
|
|
12
|
+
reportCompressedSize: false,
|
|
13
|
+
minify: true,
|
|
14
|
+
sourcemap: false,
|
|
15
|
+
},
|
|
16
|
+
server: {
|
|
17
|
+
port: 3000,
|
|
18
|
+
open: true,
|
|
19
|
+
},
|
|
20
|
+
});
|