react-inspector-devtools 0.0.0-stage → 0.1.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 (76) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +199 -2
  3. package/dist/DevtoolsApp.d.ts +1 -0
  4. package/dist/InspectorDevTools.d.ts +8 -0
  5. package/dist/components/ConfirmDialog/index.d.ts +12 -0
  6. package/dist/components/ContextMenu/index.d.ts +27 -0
  7. package/dist/components/DevToolsContainer/index.d.ts +3 -0
  8. package/dist/components/ErrorBoundary/index.d.ts +18 -0
  9. package/dist/components/Icons/index.d.ts +39 -0
  10. package/dist/components/ObjectInspector/index.d.ts +28 -0
  11. package/dist/components/SplitPane/index.d.ts +17 -0
  12. package/dist/components/StatusBar/index.d.ts +2 -0
  13. package/dist/components/Toolbar/index.d.ts +6 -0
  14. package/dist/core/eventBus.d.ts +32 -0
  15. package/dist/core/ownership.d.ts +9 -0
  16. package/dist/core/panelRegistry.d.ts +9 -0
  17. package/dist/hooks/useConfig.d.ts +13 -0
  18. package/dist/hooks/useDevtoolsContext.d.ts +8 -0
  19. package/dist/hooks/useDrag.d.ts +6 -0
  20. package/dist/hooks/useThemeResolved.d.ts +2 -0
  21. package/dist/index.cjs +10667 -0
  22. package/dist/index.cjs.map +1 -0
  23. package/dist/index.d.ts +6 -0
  24. package/dist/index.js +10662 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/inspectors/CSSInspector/BoxModel.d.ts +4 -0
  27. package/dist/inspectors/CSSInspector/ComputedPane.d.ts +3 -0
  28. package/dist/inspectors/CSSInspector/StylesPane.d.ts +3 -0
  29. package/dist/inspectors/CSSInspector/cssModel.d.ts +72 -0
  30. package/dist/inspectors/CookieInspector/index.d.ts +1 -0
  31. package/dist/inspectors/DOMInspector/DOMTree.d.ts +1 -0
  32. package/dist/inspectors/DOMInspector/Overlay.d.ts +2 -0
  33. package/dist/inspectors/DOMInspector/PropertiesPane.d.ts +7 -0
  34. package/dist/inspectors/DOMInspector/treeModel.d.ts +19 -0
  35. package/dist/inspectors/DOMInspector/usePicker.d.ts +6 -0
  36. package/dist/inspectors/StorageInspector/index.d.ts +10 -0
  37. package/dist/inspectors/StorageInspector/providers.d.ts +2 -0
  38. package/dist/instrumentation/console/index.d.ts +10 -0
  39. package/dist/instrumentation/dom/index.d.ts +9 -0
  40. package/dist/instrumentation/errors/index.d.ts +5 -0
  41. package/dist/instrumentation/index.d.ts +26 -0
  42. package/dist/instrumentation/network/fetch.d.ts +9 -0
  43. package/dist/instrumentation/network/resources.d.ts +15 -0
  44. package/dist/instrumentation/network/shared.d.ts +26 -0
  45. package/dist/instrumentation/network/xhr.d.ts +10 -0
  46. package/dist/instrumentation/storage/index.d.ts +9 -0
  47. package/dist/panels/Application/index.d.ts +1 -0
  48. package/dist/panels/Console/ConsoleInput.d.ts +3 -0
  49. package/dist/panels/Console/evaluate.d.ts +26 -0
  50. package/dist/panels/Console/format.d.ts +8 -0
  51. package/dist/panels/Console/index.d.ts +1 -0
  52. package/dist/panels/DeviceToolbar/emulation.d.ts +34 -0
  53. package/dist/panels/DeviceToolbar/index.d.ts +1 -0
  54. package/dist/panels/Elements/index.d.ts +1 -0
  55. package/dist/panels/Network/RequestDetails.d.ts +5 -0
  56. package/dist/panels/Network/index.d.ts +1 -0
  57. package/dist/panels/Network/util.d.ts +11 -0
  58. package/dist/panels/Settings/index.d.ts +1 -0
  59. package/dist/panels/index.d.ts +3 -0
  60. package/dist/store/applicationStore.d.ts +10 -0
  61. package/dist/store/consoleStore.d.ts +30 -0
  62. package/dist/store/deviceStore.d.ts +24 -0
  63. package/dist/store/devtoolsStore.d.ts +49 -0
  64. package/dist/store/elementsStore.d.ts +24 -0
  65. package/dist/store/networkStore.d.ts +33 -0
  66. package/dist/themes/index.d.ts +1 -0
  67. package/dist/types/index.d.ts +158 -0
  68. package/dist/utils/cookies.d.ts +32 -0
  69. package/dist/utils/domSelector.d.ts +4 -0
  70. package/dist/utils/format.d.ts +15 -0
  71. package/dist/utils/mediaQuery.d.ts +19 -0
  72. package/dist/utils/safeStorage.d.ts +10 -0
  73. package/dist/utils/shortcut.d.ts +15 -0
  74. package/dist/utils/specificity.d.ts +6 -0
  75. package/dist/utils/stack.d.ts +2 -0
  76. package/package.json +66 -4
@@ -0,0 +1,158 @@
1
+ import type { ComponentType } from 'react';
2
+ export type BuiltInPanelId = 'elements' | 'console' | 'network' | 'application';
3
+ export type PanelId = BuiltInPanelId | 'settings' | (string & {});
4
+ export type DockPosition = 'bottom' | 'right' | 'floating';
5
+ export type ThemeSetting = 'system' | 'light' | 'dark';
6
+ export type ResolvedTheme = 'light' | 'dark';
7
+ export interface InspectorOptions {
8
+ enableElementPicker?: boolean;
9
+ enableDeviceToolbar?: boolean;
10
+ enableConsole?: boolean;
11
+ enableNetwork?: boolean;
12
+ enableApplication?: boolean;
13
+ /** Emulate width/height media queries, matchMedia and window.innerWidth in device mode. Default true. */
14
+ emulateMediaQueries?: boolean;
15
+ }
16
+ export interface InspectorDevToolsProps {
17
+ /** Master switch. When false nothing is rendered and nothing is instrumented. Default true. */
18
+ enabled?: boolean;
19
+ /** Open the panel on first mount (persisted state wins afterwards). Default false. */
20
+ defaultOpen?: boolean;
21
+ /** Controlled open state. */
22
+ open?: boolean;
23
+ onOpenChange?: (open: boolean) => void;
24
+ position?: DockPosition;
25
+ theme?: ThemeSetting;
26
+ /** Initial height when docked to the bottom (px). */
27
+ height?: number;
28
+ /** Initial width when docked to the right (px). */
29
+ width?: number;
30
+ /** Keyboard shortcut, e.g. "Ctrl+Shift+D". "Ctrl" also matches Cmd on macOS. Pass false to disable. */
31
+ shortcut?: string | false;
32
+ /** Built-in panels to show, in order. */
33
+ panels?: BuiltInPanelId[];
34
+ /** Additional custom panels. */
35
+ customPanels?: PanelDefinition[];
36
+ options?: InspectorOptions;
37
+ /** CSS selector or element for the app root used by the device toolbar. Auto-detected by default. */
38
+ target?: string | HTMLElement;
39
+ /** Show a small floating launcher button when the tools are closed. Default true. */
40
+ showLauncher?: boolean;
41
+ /** When docked, push page content aside instead of overlaying it. Default false. */
42
+ dockPushesContent?: boolean;
43
+ maxConsoleEntries?: number;
44
+ maxNetworkEntries?: number;
45
+ /** Requests whose URL matches are not recorded (e.g. HMR / analytics). */
46
+ ignoreUrls?: (string | RegExp)[];
47
+ /** z-index of the devtools layer. */
48
+ zIndex?: number;
49
+ }
50
+ export interface PanelDefinition {
51
+ id: string;
52
+ title: string;
53
+ icon?: ComponentType<{
54
+ size?: number;
55
+ }>;
56
+ component: ComponentType;
57
+ order?: number;
58
+ }
59
+ export type ConsoleLevel = 'log' | 'info' | 'warn' | 'error' | 'debug';
60
+ export type ConsoleEntryKind = 'log' | 'table' | 'group-start' | 'group-end' | 'trace' | 'exception' | 'rejection' | 'input' | 'result' | 'system';
61
+ export interface ConsoleEntry {
62
+ id: number;
63
+ level: ConsoleLevel;
64
+ kind: ConsoleEntryKind;
65
+ /** The original console method, if any. */
66
+ method?: string;
67
+ args: unknown[];
68
+ timestamp: number;
69
+ stack?: string;
70
+ /** Indentation depth from console.group nesting. */
71
+ depth: number;
72
+ /** For group-start entries: whether the group starts collapsed. */
73
+ collapsed?: boolean;
74
+ /** Id of the enclosing group-start entry chain. */
75
+ groupPath: number[];
76
+ /** Number of identical consecutive messages collapsed into this one. */
77
+ repeat: number;
78
+ /** Source location, e.g. "app.tsx:12" */
79
+ source?: string;
80
+ /** Entry restored from a previous page load (args are plain strings). */
81
+ preserved?: boolean;
82
+ /** Columns for console.table */
83
+ columns?: string[];
84
+ }
85
+ export type ResourceType = 'fetch' | 'xhr' | 'js' | 'css' | 'doc' | 'font' | 'img' | 'media' | 'manifest' | 'ws' | 'other';
86
+ export type RequestState = 'pending' | 'complete' | 'failed' | 'aborted';
87
+ export type BodyState = 'none' | 'pending' | 'available' | 'truncated' | 'unavailable' | 'binary' | 'streaming';
88
+ export interface RequestPayload {
89
+ kind: 'text' | 'json' | 'form' | 'urlencoded' | 'binary' | 'none' | 'unknown';
90
+ text?: string;
91
+ /** For form / urlencoded payloads */
92
+ fields?: [string, string][];
93
+ size?: number;
94
+ }
95
+ export interface WebSocketFrame {
96
+ direction: 'send' | 'receive';
97
+ data: string;
98
+ size: number;
99
+ time: number;
100
+ opcode: 'text' | 'binary';
101
+ }
102
+ export interface NetworkTiming {
103
+ startTime: number;
104
+ redirect?: number;
105
+ dns?: number;
106
+ connect?: number;
107
+ ssl?: number;
108
+ request?: number;
109
+ waiting?: number;
110
+ download?: number;
111
+ total?: number;
112
+ }
113
+ export interface NetworkRequest {
114
+ id: string;
115
+ url: string;
116
+ method: string;
117
+ type: ResourceType;
118
+ initiator: string;
119
+ /** Call-site stack of the initiator, if captured */
120
+ initiatorStack?: string;
121
+ state: RequestState;
122
+ status?: number;
123
+ statusText?: string;
124
+ requestHeaders: [string, string][];
125
+ responseHeaders: [string, string][];
126
+ payload?: RequestPayload;
127
+ responseBody?: string;
128
+ /** object URL for image previews */
129
+ responseObjectUrl?: string;
130
+ bodyState: BodyState;
131
+ mimeType?: string;
132
+ /** performance.now() based */
133
+ startTime: number;
134
+ endTime?: number;
135
+ /** Date.now() based */
136
+ wallTime: number;
137
+ requestSize?: number;
138
+ responseSize?: number;
139
+ transferSize?: number;
140
+ fromCache?: boolean;
141
+ timing?: NetworkTiming;
142
+ error?: string;
143
+ responseType?: string;
144
+ redirected?: boolean;
145
+ frames?: WebSocketFrame[];
146
+ preserved?: boolean;
147
+ }
148
+ export interface DevicePreset {
149
+ id: string;
150
+ name: string;
151
+ width: number;
152
+ height: number;
153
+ dpr: number;
154
+ category: 'mobile' | 'tablet' | 'desktop' | 'custom';
155
+ touch?: boolean;
156
+ userAgent?: string;
157
+ }
158
+ export type StorageArea = 'local' | 'session';
@@ -0,0 +1,32 @@
1
+ export interface CookieRecord {
2
+ name: string;
3
+ value: string;
4
+ domain?: string;
5
+ path?: string;
6
+ /** epoch ms, or undefined for session cookies / unknown */
7
+ expires?: number;
8
+ size: number;
9
+ httpOnly?: boolean;
10
+ secure?: boolean;
11
+ sameSite?: string;
12
+ partitioned?: boolean;
13
+ /** Which attributes could actually be read from the browser. */
14
+ source: 'document.cookie' | 'cookieStore';
15
+ }
16
+ /** Parses a document.cookie string. Only name/value are available through this API. */
17
+ export declare function parseDocumentCookie(str: string): CookieRecord[];
18
+ export interface CookieWrite {
19
+ name: string;
20
+ value: string;
21
+ domain?: string;
22
+ path?: string;
23
+ expires?: number | null;
24
+ maxAge?: number | null;
25
+ secure?: boolean;
26
+ sameSite?: string;
27
+ }
28
+ export declare function serializeCookie(c: CookieWrite): string;
29
+ export declare function readCookies(): Promise<CookieRecord[]>;
30
+ export declare function writeCookie(c: CookieWrite): void;
31
+ /** Deletes a cookie, trying the provided path/domain plus common fallbacks. */
32
+ export declare function deleteCookie(name: string, path?: string, domain?: string): void;
@@ -0,0 +1,4 @@
1
+ /** Builds a reasonably short unique CSS selector for an element. */
2
+ export declare function cssPath(el: Element): string;
3
+ /** Short label like div#app.container.main */
4
+ export declare function elementLabel(el: Element, maxClasses?: number): string;
@@ -0,0 +1,15 @@
1
+ export declare function formatBytes(bytes: number | undefined | null): string;
2
+ export declare function formatDuration(ms: number | undefined | null): string;
3
+ export declare function formatClock(ts: number): string;
4
+ export declare function byteLength(str: string): number;
5
+ export declare function truncate(str: string, max: number): string;
6
+ export declare function tryParseJSON(text: string | undefined): {
7
+ ok: true;
8
+ value: unknown;
9
+ } | {
10
+ ok: false;
11
+ };
12
+ export declare function clamp(n: number, min: number, max: number): number;
13
+ /** Extracts "file.js:12" from a stack line. */
14
+ export declare function sourceFromStack(stack: string | undefined, skip?: number): string | undefined;
15
+ export declare const nextId: (prefix?: string) => string;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * A small media query evaluator used by the device toolbar to emulate
3
+ * viewport-dependent media queries against a virtual viewport.
4
+ *
5
+ * Features that do not depend on the viewport (prefers-color-scheme, etc.)
6
+ * are delegated to the real `matchMedia` through the `fallback` callback.
7
+ */
8
+ export interface MediaEnv {
9
+ width: number;
10
+ height: number;
11
+ dpr: number;
12
+ touch: boolean;
13
+ }
14
+ export declare const VIEWPORT_FEATURE_RE: RegExp;
15
+ export declare function dependsOnViewport(query: string): boolean;
16
+ type Fallback = (query: string) => boolean;
17
+ export declare function evaluateMediaQueryList(text: string, env: MediaEnv, fallback: Fallback): boolean;
18
+ export declare function evaluateFeature(inner: string, env: MediaEnv, fallback: Fallback): boolean;
19
+ export {};
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Storage helpers that use the *original* Storage methods so devtools' own
3
+ * persistence never shows up as application activity.
4
+ */
5
+ export declare const INTERNAL_PREFIX = "__rid_";
6
+ /** Must be called before any Storage patching so we keep the real methods. */
7
+ export declare function captureStorageOriginals(): void;
8
+ export declare function readInternal<T>(key: string, fallback: T, kind?: 'local' | 'session'): T;
9
+ export declare function writeInternal(key: string, value: unknown, kind?: 'local' | 'session'): void;
10
+ export declare function isInternalKey(key: string): boolean;
@@ -0,0 +1,15 @@
1
+ export interface ParsedShortcut {
2
+ key: string;
3
+ ctrlOrMeta: boolean;
4
+ ctrl: boolean;
5
+ meta: boolean;
6
+ shift: boolean;
7
+ alt: boolean;
8
+ }
9
+ /**
10
+ * Parses strings like "Ctrl+Shift+D", "Cmd+Alt+I", "Mod+K".
11
+ * "Ctrl" and "Mod" match either Ctrl or Cmd (macOS), mirroring Chrome DevTools conventions.
12
+ */
13
+ export declare function parseShortcut(input: string): ParsedShortcut | null;
14
+ export declare function matchesShortcut(e: KeyboardEvent, s: ParsedShortcut): boolean;
15
+ export declare function formatShortcut(input: string): string;
@@ -0,0 +1,6 @@
1
+ export type Specificity = [number, number, number];
2
+ /** Splits a selector list on top-level commas. */
3
+ export declare function splitSelectorList(selector: string): string[];
4
+ /** Approximate CSS specificity calculation (Selectors Level 4). */
5
+ export declare function specificity(selector: string): Specificity;
6
+ export declare function compareSpecificity(x: Specificity, y: Specificity): number;
@@ -0,0 +1,2 @@
1
+ /** Current call stack with devtools-internal frames removed. */
2
+ export declare function callerStack(max?: number): string | undefined;
package/package.json CHANGED
@@ -1,6 +1,68 @@
1
1
  {
2
2
  "name": "react-inspector-devtools",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Embeddable Chrome DevTools-style developer tools for React applications: Elements, Console, Network, Application and Device Toolbar.",
5
+ "keywords": [
6
+ "react",
7
+ "devtools",
8
+ "inspector",
9
+ "debugger",
10
+ "console",
11
+ "network",
12
+ "dom",
13
+ "chrome-devtools"
14
+ ],
15
+ "license": "MIT",
16
+ "author": "Faizan Pinjari <fznpnjr4@gmail.com>",
17
+ "type": "module",
18
+ "main": "./dist/index.cjs",
19
+ "module": "./dist/index.js",
20
+ "types": "./dist/index.d.ts",
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/index.d.ts",
24
+ "import": "./dist/index.js",
25
+ "require": "./dist/index.cjs"
26
+ },
27
+ "./package.json": "./package.json"
28
+ },
29
+ "files": [
30
+ "dist",
31
+ "README.md",
32
+ "LICENSE"
33
+ ],
34
+ "sideEffects": false,
35
+ "scripts": {
36
+ "build": "vite build && tsc -p tsconfig.build.json",
37
+ "dev": "vite build --watch",
38
+ "typecheck": "tsc -p tsconfig.json --noEmit",
39
+ "test": "vitest run",
40
+ "test:watch": "vitest",
41
+ "prepublishOnly": "npm run typecheck && npm test && npm run build"
42
+ },
43
+ "peerDependencies": {
44
+ "react": ">=18.0.0",
45
+ "react-dom": ">=18.0.0"
46
+ },
47
+ "dependencies": {
48
+ "zustand": "^5.0.0"
49
+ },
50
+ "devDependencies": {
51
+ "@testing-library/react": "^16.0.0",
52
+ "@types/node": "^24.0.0",
53
+ "@types/react": "^19.0.0",
54
+ "@types/react-dom": "^19.0.0",
55
+ "@vitejs/plugin-react": "^6.0.0",
56
+ "jsdom": "^27.0.0",
57
+ "react": "^19.0.0",
58
+ "react-dom": "^19.0.0",
59
+ "vite": "^8.0.0",
60
+ "vitest": "^5.0.0"
61
+ },
62
+ "engines": {
63
+ "node": ">=18"
64
+ },
65
+ "publishConfig": {
66
+ "access": "public"
67
+ }
68
+ }