@archbase/tools 3.0.0 → 3.0.3

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Edson Martins
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Enhanced console logger with colored output and grouping
3
+ */
4
+ export declare class ArchbaseConsoleLogger {
5
+ private static instance;
6
+ private enabled;
7
+ private logLevel;
8
+ private prefix;
9
+ private constructor();
10
+ static getInstance(): ArchbaseConsoleLogger;
11
+ setEnabled(enabled: boolean): this;
12
+ setLogLevel(level: 'debug' | 'info' | 'warn' | 'error'): this;
13
+ setPrefix(prefix: string): this;
14
+ private shouldLog;
15
+ debug(message: string, ...args: any[]): void;
16
+ info(message: string, ...args: any[]): void;
17
+ warn(message: string, ...args: any[]): void;
18
+ error(message: string, error?: Error, ...args: any[]): void;
19
+ group(label: string, fn: () => void): void;
20
+ time(label: string): void;
21
+ timeEnd(label: string): void;
22
+ table(data: any[], columns?: string[]): void;
23
+ }
24
+ export declare const logger: ArchbaseConsoleLogger;
@@ -0,0 +1,24 @@
1
+ import { default as React } from 'react';
2
+ interface DebugInfo {
3
+ id: string;
4
+ timestamp: number;
5
+ type: 'render' | 'state' | 'props' | 'api' | 'performance';
6
+ component?: string;
7
+ message: string;
8
+ data?: any;
9
+ duration?: number;
10
+ }
11
+ interface ArchbaseDebugPanelProps {
12
+ enabled?: boolean;
13
+ position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
14
+ maxEntries?: number;
15
+ }
16
+ /**
17
+ * Debug panel component for development
18
+ */
19
+ export declare const ArchbaseDebugPanel: React.FC<ArchbaseDebugPanelProps>;
20
+ /**
21
+ * Helper function to emit debug events
22
+ */
23
+ export declare function emitDebugInfo(info: Omit<DebugInfo, 'id' | 'timestamp'>): void;
24
+ export {};
@@ -0,0 +1,23 @@
1
+ import { default as React } from 'react';
2
+ interface ArchbaseDataSourceInspectorProps {
3
+ /** DataSource instances to monitor */
4
+ dataSources?: Array<{
5
+ name: string;
6
+ dataSource: any;
7
+ }>;
8
+ /** Enable automatic discovery of DataSources */
9
+ autoDiscover?: boolean;
10
+ /** Hotkey to toggle inspector */
11
+ hotkey?: string;
12
+ /** Show inspector by default */
13
+ visible?: boolean;
14
+ /** Position of the floating window */
15
+ position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
16
+ /** Maximum number of operations to track */
17
+ maxOperations?: number;
18
+ }
19
+ /**
20
+ * Advanced DataSource inspector with real-time monitoring
21
+ */
22
+ export declare const ArchbaseDataSourceInspector: React.FC<ArchbaseDataSourceInspectorProps>;
23
+ export {};
@@ -0,0 +1,30 @@
1
+ import { default as React, Component, ReactNode, ErrorInfo } from 'react';
2
+ interface Props {
3
+ children: ReactNode;
4
+ fallback?: (error: Error, errorInfo: ErrorInfo) => ReactNode;
5
+ onError?: (error: Error, errorInfo: ErrorInfo) => void;
6
+ showStack?: boolean;
7
+ logToConsole?: boolean;
8
+ }
9
+ interface State {
10
+ hasError: boolean;
11
+ error: Error | null;
12
+ errorInfo: ErrorInfo | null;
13
+ errorHistory: Array<{
14
+ error: Error;
15
+ errorInfo: ErrorInfo;
16
+ timestamp: number;
17
+ }>;
18
+ }
19
+ /**
20
+ * Enhanced error boundary with debugging capabilities
21
+ */
22
+ export declare class ArchbaseErrorBoundary extends Component<Props, State> {
23
+ constructor(props: Props);
24
+ static getDerivedStateFromError(error: Error): Partial<State>;
25
+ componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
26
+ handleRetry: () => void;
27
+ handleClearHistory: () => void;
28
+ render(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
29
+ }
30
+ export {};
@@ -0,0 +1,11 @@
1
+ import { default as React } from 'react';
2
+ interface ArchbaseLocalStorageViewerProps {
3
+ prefix?: string;
4
+ onItemClick?: (key: string, value: any) => void;
5
+ showSize?: boolean;
6
+ }
7
+ /**
8
+ * Component to view and manage localStorage in development
9
+ */
10
+ export declare const ArchbaseLocalStorageViewer: React.FC<ArchbaseLocalStorageViewerProps>;
11
+ export {};
@@ -0,0 +1,83 @@
1
+ interface MemorySnapshot {
2
+ id: string;
3
+ timestamp: number;
4
+ heapUsed: number;
5
+ heapTotal: number;
6
+ external: number;
7
+ jsHeapSizeLimit: number;
8
+ totalJSHeapSize: number;
9
+ usedJSHeapSize: number;
10
+ }
11
+ interface LeakSuspicion {
12
+ type: 'memory-growth' | 'heap-limit' | 'external-growth';
13
+ severity: 'low' | 'medium' | 'high';
14
+ message: string;
15
+ trend: number[];
16
+ recommendation: string;
17
+ }
18
+ /**
19
+ * Memory leak detection utility for development
20
+ */
21
+ export declare class ArchbaseMemoryLeakDetector {
22
+ private static instance;
23
+ private snapshots;
24
+ private intervalId;
25
+ private isMonitoring;
26
+ private readonly maxSnapshots;
27
+ private readonly growthThreshold;
28
+ private readonly criticalThreshold;
29
+ private constructor();
30
+ static getInstance(): ArchbaseMemoryLeakDetector;
31
+ /**
32
+ * Start monitoring memory usage
33
+ */
34
+ startMonitoring(intervalMs?: number): void;
35
+ /**
36
+ * Stop monitoring
37
+ */
38
+ stopMonitoring(): void;
39
+ /**
40
+ * Take a memory snapshot
41
+ */
42
+ takeSnapshot(): MemorySnapshot | null;
43
+ /**
44
+ * Analyze memory patterns for potential leaks
45
+ */
46
+ analyzeMemoryPatterns(): LeakSuspicion[];
47
+ private checkMemoryGrowth;
48
+ private checkHeapLimit;
49
+ private checkExternalGrowth;
50
+ /**
51
+ * Force garbage collection (Chrome DevTools only)
52
+ */
53
+ forceGarbageCollection(): boolean;
54
+ /**
55
+ * Get memory usage statistics
56
+ */
57
+ getMemoryStats(): {
58
+ current: MemorySnapshot | null;
59
+ peak: MemorySnapshot | null;
60
+ average: number;
61
+ growth: number;
62
+ suspicions: LeakSuspicion[];
63
+ };
64
+ /**
65
+ * Get all snapshots
66
+ */
67
+ getSnapshots(): MemorySnapshot[];
68
+ /**
69
+ * Clear all snapshots
70
+ */
71
+ clearSnapshots(): void;
72
+ /**
73
+ * Export memory data
74
+ */
75
+ exportData(): string;
76
+ private isMemoryAPIAvailable;
77
+ /**
78
+ * Check if monitoring is active
79
+ */
80
+ isActive(): boolean;
81
+ }
82
+ export declare const memoryLeakDetector: ArchbaseMemoryLeakDetector;
83
+ export {};
@@ -0,0 +1,11 @@
1
+ import { default as React } from 'react';
2
+ interface ArchbaseNetworkMonitorProps {
3
+ filterUrls?: string[];
4
+ excludeUrls?: string[];
5
+ maxRequests?: number;
6
+ }
7
+ /**
8
+ * Network request monitor component
9
+ */
10
+ export declare const ArchbaseNetworkMonitor: React.FC<ArchbaseNetworkMonitorProps>;
11
+ export {};
@@ -0,0 +1,15 @@
1
+ import { default as React } from 'react';
2
+ interface ArchbaseStateInspectorProps {
3
+ stores?: Array<{
4
+ name: string;
5
+ type: 'redux' | 'zustand' | 'context' | 'custom';
6
+ getState: () => any;
7
+ subscribe?: (listener: () => void) => () => void;
8
+ }>;
9
+ maxSnapshots?: number;
10
+ }
11
+ /**
12
+ * State inspector for debugging application state
13
+ */
14
+ export declare const ArchbaseStateInspector: React.FC<ArchbaseStateInspectorProps>;
15
+ export {};
@@ -0,0 +1,111 @@
1
+ interface DataSourceDebugOptions {
2
+ /** Enable automatic operation logging */
3
+ logOperations?: boolean;
4
+ /** Enable state change monitoring */
5
+ monitorState?: boolean;
6
+ /** Enable performance tracking */
7
+ trackPerformance?: boolean;
8
+ /** Maximum number of operations to keep in history */
9
+ maxHistory?: number;
10
+ }
11
+ interface DataSourceOperation {
12
+ id: string;
13
+ timestamp: number;
14
+ operation: string;
15
+ args?: any[];
16
+ duration?: number;
17
+ result?: any;
18
+ error?: any;
19
+ }
20
+ /**
21
+ * Hook for debugging DataSource operations and state
22
+ */
23
+ export declare function useArchbaseDataSourceDebug<T, ID>(dataSource: any, name: string, options?: DataSourceDebugOptions): {
24
+ operations: DataSourceOperation[];
25
+ currentState: any;
26
+ performanceStats: {
27
+ method: string;
28
+ count: number;
29
+ avgDuration: number;
30
+ minDuration: number;
31
+ maxDuration: number;
32
+ totalDuration: number;
33
+ }[];
34
+ getOperationHistory: (methodName?: string) => DataSourceOperation[];
35
+ clearHistory: () => void;
36
+ exportDebugData: () => {
37
+ dataSourceName: string;
38
+ currentState: any;
39
+ operations: DataSourceOperation[];
40
+ performanceStats: {
41
+ method: string;
42
+ count: number;
43
+ avgDuration: number;
44
+ minDuration: number;
45
+ maxDuration: number;
46
+ totalDuration: number;
47
+ }[];
48
+ exportedAt: string;
49
+ };
50
+ };
51
+ /**
52
+ * Hook to register multiple DataSources for debugging
53
+ */
54
+ /**
55
+ * useArchbaseDataSourceRegistry — hook que mantém múltiplos DataSources registrados para debug.
56
+ * @status stable
57
+ */
58
+ export declare function useArchbaseDataSourceRegistry(): {
59
+ dataSources: {
60
+ name: string;
61
+ dataSource: any;
62
+ debugHook: ReturnType<typeof useArchbaseDataSourceDebug>;
63
+ }[];
64
+ registerDataSource: (name: string, dataSource: any, options?: DataSourceDebugOptions) => void;
65
+ unregisterDataSource: (name: string) => void;
66
+ getDataSource: (name: string) => {
67
+ name: string;
68
+ dataSource: any;
69
+ debugHook: ReturnType<typeof useArchbaseDataSourceDebug>;
70
+ } | undefined;
71
+ getAllDataSources: () => {
72
+ name: string;
73
+ dataSource: any;
74
+ debugHook: ReturnType<typeof useArchbaseDataSourceDebug>;
75
+ }[];
76
+ exportAllDebugData: () => {
77
+ dataSources: {
78
+ name: string;
79
+ debugData: {
80
+ operations: DataSourceOperation[];
81
+ currentState: any;
82
+ performanceStats: {
83
+ method: string;
84
+ count: number;
85
+ avgDuration: number;
86
+ minDuration: number;
87
+ maxDuration: number;
88
+ totalDuration: number;
89
+ }[];
90
+ getOperationHistory: (methodName?: string) => DataSourceOperation[];
91
+ clearHistory: () => void;
92
+ exportDebugData: () => {
93
+ dataSourceName: string;
94
+ currentState: any;
95
+ operations: DataSourceOperation[];
96
+ performanceStats: {
97
+ method: string;
98
+ count: number;
99
+ avgDuration: number;
100
+ minDuration: number;
101
+ maxDuration: number;
102
+ totalDuration: number;
103
+ }[];
104
+ exportedAt: string;
105
+ };
106
+ };
107
+ }[];
108
+ exportedAt: string;
109
+ };
110
+ };
111
+ export {};
@@ -0,0 +1,12 @@
1
+ export { ArchbaseConsoleLogger, logger } from './debug/ArchbaseConsoleLogger';
2
+ export { ArchbaseDebugPanel, emitDebugInfo } from './debug/ArchbaseDebugPanel';
3
+ export { ArchbasePerformanceMonitor, performanceMonitor } from './performance/ArchbasePerformanceMonitor';
4
+ export { useArchbaseRenderTracker, useArchbaseWhyDidYouRender } from './performance/useArchbaseRenderTracker';
5
+ export { ArchbaseLocalStorageViewer } from './dev-utils/ArchbaseLocalStorageViewer';
6
+ export { ArchbaseNetworkMonitor } from './dev-utils/ArchbaseNetworkMonitor';
7
+ export { ArchbaseStateInspector } from './dev-utils/ArchbaseStateInspector';
8
+ export { ArchbaseErrorBoundary } from './dev-utils/ArchbaseErrorBoundary';
9
+ export { ArchbaseMemoryLeakDetector, memoryLeakDetector } from './dev-utils/ArchbaseMemoryLeakDetector';
10
+ export { ArchbaseDataSourceInspector } from './dev-utils/ArchbaseDataSourceInspector';
11
+ export { useArchbaseDataSourceDebug, useArchbaseDataSourceRegistry } from './dev-utils/useArchbaseDataSourceDebug';
12
+ export declare const ArchbaseToolsVersion = "3.0.0";
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Performance monitoring utility
3
+ */
4
+ export declare class ArchbasePerformanceMonitor {
5
+ private static instance;
6
+ private marks;
7
+ private measures;
8
+ private constructor();
9
+ static getInstance(): ArchbasePerformanceMonitor;
10
+ /**
11
+ * Start measuring performance
12
+ */
13
+ start(label: string): void;
14
+ /**
15
+ * End measurement and return duration
16
+ */
17
+ end(label: string): number | null;
18
+ /**
19
+ * Get statistics for a label
20
+ */
21
+ getStats(label: string): {
22
+ count: number;
23
+ total: number;
24
+ average: number;
25
+ min: number;
26
+ max: number;
27
+ median: number;
28
+ } | null;
29
+ /**
30
+ * Clear all measurements
31
+ */
32
+ clear(label?: string): void;
33
+ /**
34
+ * Get all statistics
35
+ */
36
+ getAllStats(): Map<string, ReturnType<typeof this.getStats>>;
37
+ /**
38
+ * Print performance report to console
39
+ */
40
+ report(): void;
41
+ }
42
+ export declare const performanceMonitor: ArchbasePerformanceMonitor;
@@ -0,0 +1,16 @@
1
+ interface RenderInfo {
2
+ componentName: string;
3
+ renderCount: number;
4
+ lastRenderTime: number;
5
+ averageRenderTime: number;
6
+ props?: Record<string, any>;
7
+ }
8
+ /**
9
+ * Hook to track component render performance
10
+ */
11
+ export declare function useArchbaseRenderTracker(componentName: string, props?: Record<string, any>): RenderInfo;
12
+ /**
13
+ * Hook to track why a component re-rendered
14
+ */
15
+ export declare function useArchbaseWhyDidYouRender(componentName: string, props: Record<string, any>): void;
16
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@archbase/tools",
3
- "version": "3.0.0",
3
+ "version": "3.0.3",
4
4
  "description": "Archbase React Tools - CLI, Development Tools, Generators",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -16,23 +16,25 @@
16
16
  "dist"
17
17
  ],
18
18
  "peerDependencies": {
19
- "react": "^19.0.0",
20
- "react-dom": "^19.0.0",
21
19
  "@mantine/core": "8.3.12",
22
20
  "@mantine/hooks": "8.3.12",
23
- "@tabler/icons-react": "^3.0.0"
21
+ "@tabler/icons-react": "^3.0.0",
22
+ "react": "^19.2.0",
23
+ "react-dom": "^19.2.0"
24
24
  },
25
25
  "dependencies": {
26
- "@archbase/core": "3.0.0"
26
+ "@archbase/core": "3.0.3"
27
27
  },
28
28
  "devDependencies": {
29
- "@types/react": "^19.0.2",
29
+ "@types/react": "^19.0.6",
30
30
  "@types/react-dom": "^19.0.2",
31
31
  "typescript": "^5.7.2",
32
- "vite": "^6.3.5"
32
+ "vite": "^6.3.5",
33
+ "vite-plugin-dts": "^4.5.4"
33
34
  },
35
+ "module": "./dist/index.js",
34
36
  "scripts": {
35
- "build": "NODE_OPTIONS=\"--max-old-space-size=16384\" vite build && tsc --emitDeclarationOnly || true",
37
+ "build": "NODE_OPTIONS=\"--max-old-space-size=16384\" vite build",
36
38
  "typecheck": "tsc --noEmit",
37
39
  "lint": "eslint src --ext .ts,.tsx",
38
40
  "clean": "rm -rf dist"
Binary file