@rozenite/performance-monitor-plugin 1.0.0-alpha.11

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 (58) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +130 -0
  3. package/dist/App.html +31 -0
  4. package/dist/assets/App-C1ubeKf9.js +119 -0
  5. package/dist/assets/App-DRvEE1L4.css +1 -0
  6. package/dist/react-native.cjs +1 -0
  7. package/dist/react-native.d.ts +1 -0
  8. package/dist/react-native.js +5 -0
  9. package/dist/rozenite.config.d.ts +7 -0
  10. package/dist/rozenite.json +1 -0
  11. package/dist/src/react-native/asserts.d.ts +4 -0
  12. package/dist/src/react-native/helpers.d.ts +1 -0
  13. package/dist/src/react-native/performance-monitor.d.ts +8 -0
  14. package/dist/src/react-native/usePerformanceMonitorDevTools.d.ts +1 -0
  15. package/dist/src/shared/types.d.ts +39 -0
  16. package/dist/src/ui/App.d.ts +1 -0
  17. package/dist/src/ui/components/DataTable.d.ts +8 -0
  18. package/dist/src/ui/components/DetailsDisplay.d.ts +4 -0
  19. package/dist/src/ui/components/DetailsSidebar.d.ts +6 -0
  20. package/dist/src/ui/components/ExportModal.d.ts +9 -0
  21. package/dist/src/ui/components/JsonTree.d.ts +4 -0
  22. package/dist/src/ui/components/MarkDetails.d.ts +5 -0
  23. package/dist/src/ui/components/MarksTable.d.ts +6 -0
  24. package/dist/src/ui/components/MeasureDetails.d.ts +5 -0
  25. package/dist/src/ui/components/MeasuresTable.d.ts +6 -0
  26. package/dist/src/ui/components/MetricDetails.d.ts +5 -0
  27. package/dist/src/ui/components/MetricsTable.d.ts +6 -0
  28. package/dist/src/ui/components/SessionDuration.d.ts +5 -0
  29. package/dist/src/ui/utils.d.ts +2 -0
  30. package/dist/usePerformanceMonitorDevTools.cjs +1 -0
  31. package/dist/usePerformanceMonitorDevTools.js +118 -0
  32. package/package.json +41 -0
  33. package/project.json +12 -0
  34. package/react-native.ts +8 -0
  35. package/rozenite.config.ts +8 -0
  36. package/src/react-native/asserts.ts +29 -0
  37. package/src/react-native/helpers.ts +4 -0
  38. package/src/react-native/performance-monitor.ts +171 -0
  39. package/src/react-native/usePerformanceMonitorDevTools.ts +31 -0
  40. package/src/shared/types.ts +50 -0
  41. package/src/ui/App.css +97 -0
  42. package/src/ui/App.tsx +286 -0
  43. package/src/ui/components/DataTable.tsx +117 -0
  44. package/src/ui/components/DetailsDisplay.tsx +26 -0
  45. package/src/ui/components/DetailsSidebar.tsx +87 -0
  46. package/src/ui/components/ExportModal.tsx +278 -0
  47. package/src/ui/components/JsonTree.tsx +35 -0
  48. package/src/ui/components/MarkDetails.tsx +45 -0
  49. package/src/ui/components/MarksTable.tsx +42 -0
  50. package/src/ui/components/MeasureDetails.tsx +74 -0
  51. package/src/ui/components/MeasuresTable.tsx +72 -0
  52. package/src/ui/components/MetricDetails.tsx +56 -0
  53. package/src/ui/components/MetricsTable.tsx +54 -0
  54. package/src/ui/components/SessionDuration.tsx +54 -0
  55. package/src/ui/utils.ts +17 -0
  56. package/tsconfig.json +32 -0
  57. package/tsconfig.tsbuildinfo +1 -0
  58. package/vite.config.ts +20 -0
@@ -0,0 +1,54 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { Text } from '@radix-ui/themes';
3
+
4
+ export type SessionDurationProps = {
5
+ isActive: boolean;
6
+ sessionStartedAt: number;
7
+ };
8
+
9
+ export const SessionDuration = ({
10
+ isActive,
11
+ sessionStartedAt,
12
+ }: SessionDurationProps) => {
13
+ const [currentTime, setCurrentTime] = useState<number | null>(null);
14
+
15
+ useEffect(() => {
16
+ if (!isActive) {
17
+ return;
18
+ }
19
+
20
+ setCurrentTime(Date.now());
21
+ const interval = setInterval(() => {
22
+ setCurrentTime(Date.now());
23
+ }, 1000);
24
+
25
+ return () => clearInterval(interval);
26
+ }, [isActive]);
27
+
28
+ const formatTime = (timestamp: number) => {
29
+ return new Date(timestamp).toLocaleTimeString();
30
+ };
31
+
32
+ const formatDuration = (duration: number) => {
33
+ return `${Math.round(duration)}s`;
34
+ };
35
+
36
+ const getSessionDuration = () => {
37
+ if (!currentTime || !sessionStartedAt) return 0;
38
+ return currentTime - sessionStartedAt;
39
+ };
40
+
41
+ return (
42
+ <>
43
+ <Text size="2" color="gray">
44
+ Session started:{' '}
45
+ {sessionStartedAt ? formatTime(sessionStartedAt) : 'Not started'}
46
+ </Text>
47
+ {!!sessionStartedAt && (
48
+ <Text size="2" color="gray">
49
+ Duration: {formatDuration(getSessionDuration() / 1000)}
50
+ </Text>
51
+ )}
52
+ </>
53
+ );
54
+ };
@@ -0,0 +1,17 @@
1
+ export const downloadFile = async (data: unknown, filename: string) => {
2
+ const json = JSON.stringify(data, null, 2);
3
+ const blob = new Blob([json], { type: 'application/json' });
4
+
5
+ const url = URL.createObjectURL(blob);
6
+ const link = document.createElement('a');
7
+ link.href = url;
8
+ link.download = filename;
9
+ document.body.appendChild(link);
10
+ link.click();
11
+ document.body.removeChild(link);
12
+ URL.revokeObjectURL(url);
13
+ };
14
+
15
+ export const formatTime = (timestamp: number): string => {
16
+ return new Date(timestamp).toLocaleTimeString();
17
+ };
package/tsconfig.json ADDED
@@ -0,0 +1,32 @@
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": ["src/**/*", "react-native.ts", "rozenite.config.ts"],
20
+ "exclude": ["node_modules", "dist", "build"],
21
+ "references": [
22
+ {
23
+ "path": "../plugin-bridge"
24
+ },
25
+ {
26
+ "path": "../cli"
27
+ },
28
+ {
29
+ "path": "../vite-plugin"
30
+ }
31
+ ]
32
+ }
@@ -0,0 +1 @@
1
+ {"root":["./src/react-native/usehandledevtoolsmessages.ts","./src/react-native/usehandleinitialdata.ts","./src/react-native/usesynctanstackcache.ts","./src/react-native/usetanstackquerydevtools.ts","./src/shared/dehydrate.ts","./src/shared/hydrate.ts","./src/shared/messaging.ts","./src/shared/types.ts","./src/shared/usesynconlinestatus.ts","./src/ui/tanstack-query.tsx","./src/ui/usehandlesyncmessages.ts","./src/ui/usesyncdevtoolsevents.ts","./src/ui/usesyncinitialdata.ts","./react-native.ts","./rozenite.config.ts"],"errors":true,"version":"5.8.3"}
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
+ });