@okyrychenko-dev/react-action-guard-devtools 0.1.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 +21 -0
- package/README.md +394 -0
- package/dist/index.cjs +893 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +363 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.cts +160 -0
- package/dist/index.d.ts +160 -0
- package/dist/index.js +882 -0
- package/dist/index.js.map +1 -0
- package/package.json +99 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { BlockingAction, UIBlockingStore, Middleware } from '@okyrychenko-dev/react-action-guard';
|
|
3
|
+
import { StoreApi } from 'zustand';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Extended event stored in devtools history
|
|
7
|
+
*/
|
|
8
|
+
interface DevtoolsEvent {
|
|
9
|
+
/** Unique event identifier */
|
|
10
|
+
id: string;
|
|
11
|
+
/** The action that occurred */
|
|
12
|
+
action: BlockingAction;
|
|
13
|
+
/** ID of the blocker */
|
|
14
|
+
blockerId: string;
|
|
15
|
+
/** Blocker configuration at time of event */
|
|
16
|
+
config?: {
|
|
17
|
+
scope?: string | ReadonlyArray<string>;
|
|
18
|
+
reason?: string;
|
|
19
|
+
priority?: number;
|
|
20
|
+
};
|
|
21
|
+
/** Unix timestamp of the event */
|
|
22
|
+
timestamp: number;
|
|
23
|
+
/** Previous state (available on remove/update) */
|
|
24
|
+
prevState?: {
|
|
25
|
+
scope?: string | ReadonlyArray<string>;
|
|
26
|
+
reason?: string;
|
|
27
|
+
priority?: number;
|
|
28
|
+
};
|
|
29
|
+
/** Duration in ms (calculated for remove events) */
|
|
30
|
+
duration?: number;
|
|
31
|
+
/** Source of the blocking action */
|
|
32
|
+
source?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Filter configuration for the timeline
|
|
36
|
+
*/
|
|
37
|
+
interface DevtoolsFilter {
|
|
38
|
+
/** Filter by action types */
|
|
39
|
+
actions: Array<BlockingAction>;
|
|
40
|
+
/** Filter by scope */
|
|
41
|
+
scopes: Array<string>;
|
|
42
|
+
/** Search query for blocker IDs */
|
|
43
|
+
search: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Position of the devtools panel
|
|
47
|
+
*/
|
|
48
|
+
type DevtoolsPosition = "left" | "right";
|
|
49
|
+
/**
|
|
50
|
+
* Devtools store state
|
|
51
|
+
*/
|
|
52
|
+
interface DevtoolsState {
|
|
53
|
+
/** Event history */
|
|
54
|
+
events: Array<DevtoolsEvent>;
|
|
55
|
+
/** Maximum number of events to keep */
|
|
56
|
+
maxEvents: number;
|
|
57
|
+
/** Whether the panel is open */
|
|
58
|
+
isOpen: boolean;
|
|
59
|
+
/** Whether the panel is minimized */
|
|
60
|
+
isMinimized: boolean;
|
|
61
|
+
/** Active tab in the panel */
|
|
62
|
+
activeTab: "timeline" | "blockers";
|
|
63
|
+
/** Current filter settings */
|
|
64
|
+
filter: DevtoolsFilter;
|
|
65
|
+
/** Selected event for detail view */
|
|
66
|
+
selectedEventId: string | null;
|
|
67
|
+
/** Whether devtools is paused (stops recording) */
|
|
68
|
+
isPaused: boolean;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Devtools store actions
|
|
72
|
+
*/
|
|
73
|
+
interface DevtoolsActions {
|
|
74
|
+
/** Add a new event to history */
|
|
75
|
+
addEvent: (event: Omit<DevtoolsEvent, "id">) => void;
|
|
76
|
+
/** Clear all events */
|
|
77
|
+
clearEvents: VoidFunction;
|
|
78
|
+
/** Toggle panel open/closed */
|
|
79
|
+
toggleOpen: VoidFunction;
|
|
80
|
+
/** Set panel open state */
|
|
81
|
+
setOpen: (open: boolean) => void;
|
|
82
|
+
/** Toggle minimized state */
|
|
83
|
+
toggleMinimized: VoidFunction;
|
|
84
|
+
/** Set active tab */
|
|
85
|
+
setActiveTab: (tab: DevtoolsState["activeTab"]) => void;
|
|
86
|
+
/** Update filter settings */
|
|
87
|
+
setFilter: (filter: Partial<DevtoolsFilter>) => void;
|
|
88
|
+
/** Reset filters to default */
|
|
89
|
+
resetFilter: VoidFunction;
|
|
90
|
+
/** Select an event for detail view */
|
|
91
|
+
selectEvent: (eventId: string | null) => void;
|
|
92
|
+
/** Toggle pause state */
|
|
93
|
+
togglePause: VoidFunction;
|
|
94
|
+
/** Set max events limit */
|
|
95
|
+
setMaxEvents: (max: number) => void;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Complete devtools store type
|
|
99
|
+
*/
|
|
100
|
+
type DevtoolsStore = DevtoolsState & DevtoolsActions;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Store API type for UIBlockingProvider integration
|
|
104
|
+
*/
|
|
105
|
+
type UIBlockingStoreApi = StoreApi<UIBlockingStore>;
|
|
106
|
+
/**
|
|
107
|
+
* Props for the main ActionGuardDevtools component
|
|
108
|
+
*/
|
|
109
|
+
interface ActionGuardDevtoolsProps {
|
|
110
|
+
/** Position of the toggle button and panel */
|
|
111
|
+
position?: DevtoolsPosition;
|
|
112
|
+
/** Whether the panel is open by default */
|
|
113
|
+
defaultOpen?: boolean;
|
|
114
|
+
/** Maximum number of events to store */
|
|
115
|
+
maxEvents?: number;
|
|
116
|
+
/** Whether to show in production (default: false) */
|
|
117
|
+
showInProduction?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Custom store instance from UIBlockingProvider.
|
|
120
|
+
* Use this when you have multiple isolated stores via UIBlockingProvider.
|
|
121
|
+
* If not provided, the global store is used.
|
|
122
|
+
*/
|
|
123
|
+
store?: UIBlockingStoreApi;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
declare function ActionGuardDevtools(props: ActionGuardDevtoolsProps): ReactElement | null;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Devtools Store
|
|
130
|
+
*
|
|
131
|
+
* Global Zustand store for managing devtools state across the application.
|
|
132
|
+
*
|
|
133
|
+
* Features:
|
|
134
|
+
* - Event history with circular buffer
|
|
135
|
+
* - Timeline filtering by action/scope/search
|
|
136
|
+
* - Pause/resume recording
|
|
137
|
+
* - Panel open/minimize states
|
|
138
|
+
* - Automatic shallow comparison for selectors
|
|
139
|
+
*/
|
|
140
|
+
declare const useDevtoolsStore: {
|
|
141
|
+
(): DevtoolsStore;
|
|
142
|
+
<T>(selector: (state: DevtoolsStore) => T): T;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Selector for filtered events
|
|
147
|
+
*/
|
|
148
|
+
declare function selectFilteredEvents(state: DevtoolsStore): Array<DevtoolsEvent>;
|
|
149
|
+
/**
|
|
150
|
+
* Get unique scopes from all events (for filter dropdown)
|
|
151
|
+
*/
|
|
152
|
+
declare function selectUniqueScopes(state: DevtoolsStore): Array<string>;
|
|
153
|
+
|
|
154
|
+
declare const DEVTOOLS_MIDDLEWARE_NAME = "action-guard-devtools";
|
|
155
|
+
/**
|
|
156
|
+
* Creates the devtools middleware that records events
|
|
157
|
+
*/
|
|
158
|
+
declare function createDevtoolsMiddleware(): Middleware;
|
|
159
|
+
|
|
160
|
+
export { ActionGuardDevtools, DEVTOOLS_MIDDLEWARE_NAME, type DevtoolsActions, type DevtoolsEvent, type DevtoolsFilter, type DevtoolsPosition, type DevtoolsState, type DevtoolsStore, createDevtoolsMiddleware, selectFilteredEvents, selectUniqueScopes, useDevtoolsStore };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { BlockingAction, UIBlockingStore, Middleware } from '@okyrychenko-dev/react-action-guard';
|
|
3
|
+
import { StoreApi } from 'zustand';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Extended event stored in devtools history
|
|
7
|
+
*/
|
|
8
|
+
interface DevtoolsEvent {
|
|
9
|
+
/** Unique event identifier */
|
|
10
|
+
id: string;
|
|
11
|
+
/** The action that occurred */
|
|
12
|
+
action: BlockingAction;
|
|
13
|
+
/** ID of the blocker */
|
|
14
|
+
blockerId: string;
|
|
15
|
+
/** Blocker configuration at time of event */
|
|
16
|
+
config?: {
|
|
17
|
+
scope?: string | ReadonlyArray<string>;
|
|
18
|
+
reason?: string;
|
|
19
|
+
priority?: number;
|
|
20
|
+
};
|
|
21
|
+
/** Unix timestamp of the event */
|
|
22
|
+
timestamp: number;
|
|
23
|
+
/** Previous state (available on remove/update) */
|
|
24
|
+
prevState?: {
|
|
25
|
+
scope?: string | ReadonlyArray<string>;
|
|
26
|
+
reason?: string;
|
|
27
|
+
priority?: number;
|
|
28
|
+
};
|
|
29
|
+
/** Duration in ms (calculated for remove events) */
|
|
30
|
+
duration?: number;
|
|
31
|
+
/** Source of the blocking action */
|
|
32
|
+
source?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Filter configuration for the timeline
|
|
36
|
+
*/
|
|
37
|
+
interface DevtoolsFilter {
|
|
38
|
+
/** Filter by action types */
|
|
39
|
+
actions: Array<BlockingAction>;
|
|
40
|
+
/** Filter by scope */
|
|
41
|
+
scopes: Array<string>;
|
|
42
|
+
/** Search query for blocker IDs */
|
|
43
|
+
search: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Position of the devtools panel
|
|
47
|
+
*/
|
|
48
|
+
type DevtoolsPosition = "left" | "right";
|
|
49
|
+
/**
|
|
50
|
+
* Devtools store state
|
|
51
|
+
*/
|
|
52
|
+
interface DevtoolsState {
|
|
53
|
+
/** Event history */
|
|
54
|
+
events: Array<DevtoolsEvent>;
|
|
55
|
+
/** Maximum number of events to keep */
|
|
56
|
+
maxEvents: number;
|
|
57
|
+
/** Whether the panel is open */
|
|
58
|
+
isOpen: boolean;
|
|
59
|
+
/** Whether the panel is minimized */
|
|
60
|
+
isMinimized: boolean;
|
|
61
|
+
/** Active tab in the panel */
|
|
62
|
+
activeTab: "timeline" | "blockers";
|
|
63
|
+
/** Current filter settings */
|
|
64
|
+
filter: DevtoolsFilter;
|
|
65
|
+
/** Selected event for detail view */
|
|
66
|
+
selectedEventId: string | null;
|
|
67
|
+
/** Whether devtools is paused (stops recording) */
|
|
68
|
+
isPaused: boolean;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Devtools store actions
|
|
72
|
+
*/
|
|
73
|
+
interface DevtoolsActions {
|
|
74
|
+
/** Add a new event to history */
|
|
75
|
+
addEvent: (event: Omit<DevtoolsEvent, "id">) => void;
|
|
76
|
+
/** Clear all events */
|
|
77
|
+
clearEvents: VoidFunction;
|
|
78
|
+
/** Toggle panel open/closed */
|
|
79
|
+
toggleOpen: VoidFunction;
|
|
80
|
+
/** Set panel open state */
|
|
81
|
+
setOpen: (open: boolean) => void;
|
|
82
|
+
/** Toggle minimized state */
|
|
83
|
+
toggleMinimized: VoidFunction;
|
|
84
|
+
/** Set active tab */
|
|
85
|
+
setActiveTab: (tab: DevtoolsState["activeTab"]) => void;
|
|
86
|
+
/** Update filter settings */
|
|
87
|
+
setFilter: (filter: Partial<DevtoolsFilter>) => void;
|
|
88
|
+
/** Reset filters to default */
|
|
89
|
+
resetFilter: VoidFunction;
|
|
90
|
+
/** Select an event for detail view */
|
|
91
|
+
selectEvent: (eventId: string | null) => void;
|
|
92
|
+
/** Toggle pause state */
|
|
93
|
+
togglePause: VoidFunction;
|
|
94
|
+
/** Set max events limit */
|
|
95
|
+
setMaxEvents: (max: number) => void;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Complete devtools store type
|
|
99
|
+
*/
|
|
100
|
+
type DevtoolsStore = DevtoolsState & DevtoolsActions;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Store API type for UIBlockingProvider integration
|
|
104
|
+
*/
|
|
105
|
+
type UIBlockingStoreApi = StoreApi<UIBlockingStore>;
|
|
106
|
+
/**
|
|
107
|
+
* Props for the main ActionGuardDevtools component
|
|
108
|
+
*/
|
|
109
|
+
interface ActionGuardDevtoolsProps {
|
|
110
|
+
/** Position of the toggle button and panel */
|
|
111
|
+
position?: DevtoolsPosition;
|
|
112
|
+
/** Whether the panel is open by default */
|
|
113
|
+
defaultOpen?: boolean;
|
|
114
|
+
/** Maximum number of events to store */
|
|
115
|
+
maxEvents?: number;
|
|
116
|
+
/** Whether to show in production (default: false) */
|
|
117
|
+
showInProduction?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Custom store instance from UIBlockingProvider.
|
|
120
|
+
* Use this when you have multiple isolated stores via UIBlockingProvider.
|
|
121
|
+
* If not provided, the global store is used.
|
|
122
|
+
*/
|
|
123
|
+
store?: UIBlockingStoreApi;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
declare function ActionGuardDevtools(props: ActionGuardDevtoolsProps): ReactElement | null;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Devtools Store
|
|
130
|
+
*
|
|
131
|
+
* Global Zustand store for managing devtools state across the application.
|
|
132
|
+
*
|
|
133
|
+
* Features:
|
|
134
|
+
* - Event history with circular buffer
|
|
135
|
+
* - Timeline filtering by action/scope/search
|
|
136
|
+
* - Pause/resume recording
|
|
137
|
+
* - Panel open/minimize states
|
|
138
|
+
* - Automatic shallow comparison for selectors
|
|
139
|
+
*/
|
|
140
|
+
declare const useDevtoolsStore: {
|
|
141
|
+
(): DevtoolsStore;
|
|
142
|
+
<T>(selector: (state: DevtoolsStore) => T): T;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Selector for filtered events
|
|
147
|
+
*/
|
|
148
|
+
declare function selectFilteredEvents(state: DevtoolsStore): Array<DevtoolsEvent>;
|
|
149
|
+
/**
|
|
150
|
+
* Get unique scopes from all events (for filter dropdown)
|
|
151
|
+
*/
|
|
152
|
+
declare function selectUniqueScopes(state: DevtoolsStore): Array<string>;
|
|
153
|
+
|
|
154
|
+
declare const DEVTOOLS_MIDDLEWARE_NAME = "action-guard-devtools";
|
|
155
|
+
/**
|
|
156
|
+
* Creates the devtools middleware that records events
|
|
157
|
+
*/
|
|
158
|
+
declare function createDevtoolsMiddleware(): Middleware;
|
|
159
|
+
|
|
160
|
+
export { ActionGuardDevtools, DEVTOOLS_MIDDLEWARE_NAME, type DevtoolsActions, type DevtoolsEvent, type DevtoolsFilter, type DevtoolsPosition, type DevtoolsState, type DevtoolsStore, createDevtoolsMiddleware, selectFilteredEvents, selectUniqueScopes, useDevtoolsStore };
|