react-native-ai-devtools-sdk 0.2.1 → 0.3.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.
@@ -1,13 +1,9 @@
1
- import { ConsoleEntry, ConsoleQueryOptions } from './types';
1
+ import { ConsoleEntry } from './types';
2
2
  export declare class ConsoleBuffer {
3
3
  private entries;
4
4
  private maxSize;
5
5
  constructor(maxSize?: number);
6
6
  add(entry: ConsoleEntry): void;
7
- query(options?: ConsoleQueryOptions): ConsoleEntry[];
8
- getStats(): {
9
- total: number;
10
- byLevel: Record<string, number>;
11
- };
7
+ getAll(): ConsoleEntry[];
12
8
  clear(): number;
13
9
  }
@@ -12,26 +12,8 @@ class ConsoleBuffer {
12
12
  }
13
13
  this.entries.push(entry);
14
14
  }
15
- query(options) {
16
- let results = [...this.entries].reverse();
17
- if (options?.level) {
18
- results = results.filter((e) => e.level === options.level);
19
- }
20
- if (options?.text) {
21
- const text = options.text.toLowerCase();
22
- results = results.filter((e) => e.message.toLowerCase().includes(text));
23
- }
24
- if (options?.count != null && options.count > 0) {
25
- results = results.slice(0, options.count);
26
- }
27
- return results;
28
- }
29
- getStats() {
30
- const byLevel = {};
31
- for (const entry of this.entries) {
32
- byLevel[entry.level] = (byLevel[entry.level] || 0) + 1;
33
- }
34
- return { total: this.entries.length, byLevel };
15
+ getAll() {
16
+ return [...this.entries];
35
17
  }
36
18
  clear() {
37
19
  const count = this.entries.length;
package/dist/global.js CHANGED
@@ -4,16 +4,14 @@ exports.exposeGlobal = exposeGlobal;
4
4
  function exposeGlobal(options) {
5
5
  const { networkBuffer, consoleBuffer, stores, navigation, custom, capabilities } = options;
6
6
  const devtools = {
7
- version: '0.2.0',
7
+ version: '0.3.0',
8
8
  capabilities,
9
9
  stores,
10
10
  navigation,
11
11
  custom,
12
- getNetworkRequests: (opts) => networkBuffer.query(opts),
13
- getNetworkRequest: (id) => networkBuffer.get(id),
14
- getNetworkStats: () => networkBuffer.getStats(),
12
+ getNetworkEntries: () => networkBuffer.getAll(),
13
+ getConsoleEntries: () => consoleBuffer.getAll(),
15
14
  clearNetwork: () => networkBuffer.clear(),
16
- getConsoleLogs: (opts) => consoleBuffer.query(opts),
17
15
  clearConsole: () => consoleBuffer.clear(),
18
16
  };
19
17
  globalThis.__RN_AI_DEVTOOLS__ = devtools;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { InitOptions } from './types';
2
- export type { InitOptions, NetworkEntry, NetworkQueryOptions, NetworkStats, ConsoleEntry, ConsoleQueryOptions, Capabilities, DevToolsGlobal, } from './types';
2
+ export type { InitOptions, NetworkEntry, ConsoleEntry, Capabilities, DevToolsGlobal, } from './types';
3
3
  export declare function init(options?: InitOptions): void;
4
4
  export declare function _resetForTesting(): void;
@@ -1,4 +1,4 @@
1
- import { NetworkEntry, NetworkQueryOptions, NetworkStats } from './types';
1
+ import { NetworkEntry } from './types';
2
2
  export declare class NetworkBuffer {
3
3
  private entries;
4
4
  private order;
@@ -7,7 +7,6 @@ export declare class NetworkBuffer {
7
7
  add(entry: NetworkEntry): void;
8
8
  update(id: string, updates: Partial<NetworkEntry>): void;
9
9
  get(id: string): NetworkEntry | null;
10
- query(options?: NetworkQueryOptions): NetworkEntry[];
11
- getStats(): NetworkStats;
10
+ getAll(): NetworkEntry[];
12
11
  clear(): number;
13
12
  }
@@ -27,66 +27,8 @@ class NetworkBuffer {
27
27
  get(id) {
28
28
  return this.entries.get(id) ?? null;
29
29
  }
30
- query(options) {
31
- let results = Array.from(this.order)
32
- .map((id) => this.entries.get(id))
33
- .reverse();
34
- if (options?.method) {
35
- const method = options.method.toUpperCase();
36
- results = results.filter((e) => e.method === method);
37
- }
38
- if (options?.urlPattern) {
39
- const pattern = options.urlPattern.toLowerCase();
40
- results = results.filter((e) => e.url.toLowerCase().includes(pattern));
41
- }
42
- if (options?.status != null) {
43
- results = results.filter((e) => e.status === options.status);
44
- }
45
- if (options?.count != null && options.count > 0) {
46
- results = results.slice(0, options.count);
47
- }
48
- return results;
49
- }
50
- getStats() {
51
- const all = Array.from(this.entries.values());
52
- const completed = all.filter((e) => e.completed && !e.error);
53
- const errors = all.filter((e) => !!e.error);
54
- const durations = completed
55
- .map((e) => e.duration)
56
- .filter((d) => d != null);
57
- const avgDuration = durations.length > 0
58
- ? durations.reduce((sum, d) => sum + d, 0) / durations.length
59
- : null;
60
- const byMethod = {};
61
- for (const entry of all) {
62
- byMethod[entry.method] = (byMethod[entry.method] || 0) + 1;
63
- }
64
- const byStatus = {};
65
- for (const entry of all) {
66
- if (entry.status != null) {
67
- const group = `${Math.floor(entry.status / 100)}xx`;
68
- byStatus[group] = (byStatus[group] || 0) + 1;
69
- }
70
- }
71
- const byDomain = {};
72
- for (const entry of all) {
73
- try {
74
- const domain = new URL(entry.url).hostname;
75
- byDomain[domain] = (byDomain[domain] || 0) + 1;
76
- }
77
- catch {
78
- // skip malformed URLs
79
- }
80
- }
81
- return {
82
- total: all.length,
83
- completed: completed.length,
84
- errors: errors.length,
85
- avgDuration,
86
- byMethod,
87
- byStatus,
88
- byDomain,
89
- };
30
+ getAll() {
31
+ return this.order.map((id) => this.entries.get(id));
90
32
  }
91
33
  clear() {
92
34
  const count = this.entries.size;
package/dist/types.d.ts CHANGED
@@ -22,32 +22,12 @@ export interface NetworkEntry {
22
22
  error?: string;
23
23
  completed: boolean;
24
24
  }
25
- export interface NetworkQueryOptions {
26
- count?: number;
27
- method?: string;
28
- urlPattern?: string;
29
- status?: number;
30
- }
31
- export interface NetworkStats {
32
- total: number;
33
- completed: number;
34
- errors: number;
35
- avgDuration: number | null;
36
- byMethod: Record<string, number>;
37
- byStatus: Record<string, number>;
38
- byDomain: Record<string, number>;
39
- }
40
25
  export interface ConsoleEntry {
41
26
  id: string;
42
27
  timestamp: number;
43
28
  level: 'log' | 'warn' | 'error' | 'info' | 'debug';
44
29
  message: string;
45
30
  }
46
- export interface ConsoleQueryOptions {
47
- count?: number;
48
- level?: 'log' | 'warn' | 'error' | 'info' | 'debug';
49
- text?: string;
50
- }
51
31
  export interface Capabilities {
52
32
  network: boolean;
53
33
  console: boolean;
@@ -61,10 +41,8 @@ export interface DevToolsGlobal {
61
41
  stores: Record<string, unknown>;
62
42
  navigation: unknown;
63
43
  custom: Record<string, unknown>;
64
- getNetworkRequests: (options?: NetworkQueryOptions) => NetworkEntry[];
65
- getNetworkRequest: (id: string) => NetworkEntry | null;
66
- getNetworkStats: () => NetworkStats;
44
+ getNetworkEntries: () => NetworkEntry[];
45
+ getConsoleEntries: () => ConsoleEntry[];
67
46
  clearNetwork: () => number;
68
- getConsoleLogs: (options?: ConsoleQueryOptions) => ConsoleEntry[];
69
47
  clearConsole: () => number;
70
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-ai-devtools-sdk",
3
- "version": "0.2.1",
3
+ "version": "0.3.1",
4
4
  "description": "Lightweight SDK for react-native-ai-devtools — captures network requests for AI-powered debugging",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",