@flight-framework/devtools 0.0.2 → 0.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.
@@ -0,0 +1,127 @@
1
+ /**
2
+ * @flight-framework/devtools - Development Tools
3
+ *
4
+ * Provides debugging tools for Flight applications during development.
5
+ * Automatically disabled in production builds.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * // In your flight.config.ts or main entry
10
+ * import { enableDevTools } from '@flight-framework/devtools';
11
+ *
12
+ * if (process.env.NODE_ENV === 'development') {
13
+ * enableDevTools({
14
+ * port: 3001,
15
+ * showRoutes: true,
16
+ * showRequests: true,
17
+ * showCache: true,
18
+ * });
19
+ * }
20
+ * ```
21
+ */
22
+ export interface DevToolsOptions {
23
+ /** WebSocket port for DevTools communication (default: 3001) */
24
+ port?: number;
25
+ /** Show registered routes */
26
+ showRoutes?: boolean;
27
+ /** Show incoming requests */
28
+ showRequests?: boolean;
29
+ /** Show cache status */
30
+ showCache?: boolean;
31
+ /** Show connected adapters */
32
+ showAdapters?: boolean;
33
+ /** Custom panel position */
34
+ position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
35
+ }
36
+ export interface RouteInfo {
37
+ method: string;
38
+ path: string;
39
+ type: 'page' | 'api';
40
+ filePath: string;
41
+ slot?: string;
42
+ interceptInfo?: {
43
+ level: number;
44
+ target: string;
45
+ };
46
+ }
47
+ export interface RequestInfo {
48
+ id: string;
49
+ method: string;
50
+ path: string;
51
+ status: number;
52
+ duration: number;
53
+ timestamp: number;
54
+ }
55
+ export interface CacheInfo {
56
+ key: string;
57
+ size: number;
58
+ hits: number;
59
+ lastAccessed: number;
60
+ }
61
+ export interface AdapterInfo {
62
+ name: string;
63
+ type: 'db' | 'auth' | 'storage' | 'email' | 'payments' | 'realtime' | 'other';
64
+ status: 'connected' | 'disconnected' | 'error';
65
+ }
66
+ export interface DevToolsState {
67
+ routes: RouteInfo[];
68
+ requests: RequestInfo[];
69
+ cache: CacheInfo[];
70
+ adapters: AdapterInfo[];
71
+ }
72
+ declare class DevToolsManager {
73
+ private options;
74
+ private state;
75
+ private subscribers;
76
+ private isEnabled;
77
+ constructor(options: DevToolsOptions);
78
+ /**
79
+ * Register routes for display in DevTools
80
+ */
81
+ registerRoutes(routes: RouteInfo[]): void;
82
+ /**
83
+ * Log a request
84
+ */
85
+ logRequest(info: Omit<RequestInfo, 'id' | 'timestamp'>): void;
86
+ /**
87
+ * Update cache info
88
+ */
89
+ updateCache(cache: CacheInfo[]): void;
90
+ /**
91
+ * Register an adapter
92
+ */
93
+ registerAdapter(adapter: AdapterInfo): void;
94
+ /**
95
+ * Subscribe to state changes
96
+ */
97
+ subscribe(callback: (state: DevToolsState) => void): () => void;
98
+ /**
99
+ * Get current state
100
+ */
101
+ getState(): DevToolsState;
102
+ /**
103
+ * Get options
104
+ */
105
+ getOptions(): Required<DevToolsOptions>;
106
+ private notify;
107
+ }
108
+ /**
109
+ * Enable DevTools for the application
110
+ */
111
+ export declare function enableDevTools(options?: DevToolsOptions): DevToolsManager;
112
+ /**
113
+ * Get the DevTools instance
114
+ */
115
+ export declare function getDevTools(): DevToolsManager | null;
116
+ /**
117
+ * Check if DevTools are enabled
118
+ */
119
+ export declare function isDevToolsEnabled(): boolean;
120
+ /**
121
+ * Middleware to log requests to DevTools
122
+ */
123
+ export declare function devToolsMiddleware(): (context: {
124
+ request: Request;
125
+ }, next: () => Promise<Response>) => Promise<Response>;
126
+ export {};
127
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAMH,MAAM,WAAW,eAAe;IAC5B,gEAAgE;IAChE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6BAA6B;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,6BAA6B;IAC7B,YAAY,CAAC,EAAE,OA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C;CAC3B;AAQD,cAAM,eAAe;IACjB,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,KAAK,CAAgB;IAC7B,OAAO,CAAC,WAAW,CAAsC;IACzD,OAAO,CAAC,SAAS,CAAU;gBAEf,OAAO,EAAE,eAAe;IAqBpC;;OAEG;IACH,cAAc,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI;IAMzC;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,GAAG,WAAW,CAAC,GAAG,IAAI;IAc7D;;OAEG;IACH,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI;IAMrC;;OAEG;IACH,eAAe,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAY3C;;OAEG;IACH,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,GAAG,MAAM,IAAI;IAM/D;;OAEG;IACH,QAAQ,IAAI,aAAa;IAIzB;;OAEG;IACH,UAAU,IAAI,QAAQ,CAAC,eAAe,CAAC;IAIvC,OAAO,CAAC,MAAM;CAKjB;AAMD;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,GAAE,eAAoB,GAAG,eAAe,CAY7E;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,eAAe,GAAG,IAAI,CAEpD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAMD;;GAEG;AACH,wBAAgB,kBAAkB,KAE1B,SAAS;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,EAC7B,MAAM,MAAM,OAAO,CAAC,QAAQ,CAAC,KAC9B,OAAO,CAAC,QAAQ,CAAC,CA+BvB"}
@@ -1,273 +1,187 @@
1
- /**
2
- * @flight-framework/devtools - Development Tools
3
- *
4
- * Provides debugging tools for Flight applications during development.
5
- * Automatically disabled in production builds.
6
- *
7
- * @example
8
- * ```typescript
9
- * // In your flight.config.ts or main entry
10
- * import { enableDevTools } from '@flight-framework/devtools';
11
- *
12
- * if (process.env.NODE_ENV === 'development') {
13
- * enableDevTools({
14
- * port: 3001,
15
- * showRoutes: true,
16
- * showRequests: true,
17
- * showCache: true,
18
- * });
19
- * }
20
- * ```
21
- */
22
-
23
- // ============================================================================
24
- // Types
25
- // ============================================================================
26
-
27
- export interface DevToolsOptions {
28
- /** WebSocket port for DevTools communication (default: 3001) */
29
- port?: number;
30
- /** Show registered routes */
31
- showRoutes?: boolean;
32
- /** Show incoming requests */
33
- showRequests?: boolean;
34
- /** Show cache status */
35
- showCache?: boolean;
36
- /** Show connected adapters */
37
- showAdapters?: boolean;
38
- /** Custom panel position */
39
- position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
40
- }
41
-
42
- export interface RouteInfo {
43
- method: string;
44
- path: string;
45
- type: 'page' | 'api';
46
- filePath: string;
47
- slot?: string;
48
- interceptInfo?: {
49
- level: number;
50
- target: string;
51
- };
52
- }
53
-
54
- export interface RequestInfo {
55
- id: string;
56
- method: string;
57
- path: string;
58
- status: number;
59
- duration: number;
60
- timestamp: number;
61
- }
62
-
63
- export interface CacheInfo {
64
- key: string;
65
- size: number;
66
- hits: number;
67
- lastAccessed: number;
68
- }
69
-
70
- export interface AdapterInfo {
71
- name: string;
72
- type: 'db' | 'auth' | 'storage' | 'email' | 'payments' | 'realtime' | 'other';
73
- status: 'connected' | 'disconnected' | 'error';
74
- }
75
-
76
- export interface DevToolsState {
77
- routes: RouteInfo[];
78
- requests: RequestInfo[];
79
- cache: CacheInfo[];
80
- adapters: AdapterInfo[];
81
- }
82
-
83
- // ============================================================================
84
- // DevTools Manager
85
- // ============================================================================
86
-
87
- let devToolsInstance: DevToolsManager | null = null;
88
-
89
- class DevToolsManager {
90
- private options: Required<DevToolsOptions>;
91
- private state: DevToolsState;
92
- private subscribers: Set<(state: DevToolsState) => void>;
93
- private isEnabled: boolean;
94
-
95
- constructor(options: DevToolsOptions) {
96
- this.options = {
97
- port: options.port ?? 3001,
98
- showRoutes: options.showRoutes ?? true,
99
- showRequests: options.showRequests ?? true,
100
- showCache: options.showCache ?? true,
101
- showAdapters: options.showAdapters ?? true,
102
- position: options.position ?? 'bottom-right',
103
- };
104
-
105
- this.state = {
106
- routes: [],
107
- requests: [],
108
- cache: [],
109
- adapters: [],
110
- };
111
-
112
- this.subscribers = new Set();
113
- this.isEnabled = process.env.NODE_ENV === 'development';
114
- }
115
-
116
- /**
117
- * Register routes for display in DevTools
118
- */
119
- registerRoutes(routes: RouteInfo[]): void {
120
- if (!this.isEnabled) return;
121
- this.state.routes = routes;
122
- this.notify();
123
- }
124
-
125
- /**
126
- * Log a request
127
- */
128
- logRequest(info: Omit<RequestInfo, 'id' | 'timestamp'>): void {
129
- if (!this.isEnabled || !this.options.showRequests) return;
130
-
131
- const request: RequestInfo = {
132
- ...info,
133
- id: crypto.randomUUID(),
134
- timestamp: Date.now(),
135
- };
136
-
137
- // Keep last 100 requests
138
- this.state.requests = [request, ...this.state.requests].slice(0, 100);
139
- this.notify();
140
- }
141
-
142
- /**
143
- * Update cache info
144
- */
145
- updateCache(cache: CacheInfo[]): void {
146
- if (!this.isEnabled || !this.options.showCache) return;
147
- this.state.cache = cache;
148
- this.notify();
149
- }
150
-
151
- /**
152
- * Register an adapter
153
- */
154
- registerAdapter(adapter: AdapterInfo): void {
155
- if (!this.isEnabled || !this.options.showAdapters) return;
156
-
157
- const existing = this.state.adapters.findIndex(a => a.name === adapter.name);
158
- if (existing >= 0) {
159
- this.state.adapters[existing] = adapter;
160
- } else {
161
- this.state.adapters.push(adapter);
162
- }
163
- this.notify();
164
- }
165
-
166
- /**
167
- * Subscribe to state changes
168
- */
169
- subscribe(callback: (state: DevToolsState) => void): () => void {
170
- this.subscribers.add(callback);
171
- callback(this.state); // Initial state
172
- return () => this.subscribers.delete(callback);
173
- }
174
-
175
- /**
176
- * Get current state
177
- */
178
- getState(): DevToolsState {
179
- return this.state;
180
- }
181
-
182
- /**
183
- * Get options
184
- */
185
- getOptions(): Required<DevToolsOptions> {
186
- return this.options;
187
- }
188
-
189
- private notify(): void {
190
- for (const callback of this.subscribers) {
191
- callback(this.state);
192
- }
193
- }
194
- }
195
-
196
- // ============================================================================
197
- // Public API
198
- // ============================================================================
199
-
200
- /**
201
- * Enable DevTools for the application
202
- */
203
- export function enableDevTools(options: DevToolsOptions = {}): DevToolsManager {
204
- if (process.env.NODE_ENV !== 'development') {
205
- console.warn('[Flight DevTools] DevTools are disabled in production');
206
- return devToolsInstance as DevToolsManager;
207
- }
208
-
209
- if (!devToolsInstance) {
210
- devToolsInstance = new DevToolsManager(options);
211
- console.log(`[Flight DevTools] Enabled on port ${options.port ?? 3001}`);
212
- }
213
-
214
- return devToolsInstance;
215
- }
216
-
217
- /**
218
- * Get the DevTools instance
219
- */
220
- export function getDevTools(): DevToolsManager | null {
221
- return devToolsInstance;
222
- }
223
-
224
- /**
225
- * Check if DevTools are enabled
226
- */
227
- export function isDevToolsEnabled(): boolean {
228
- return devToolsInstance !== null && process.env.NODE_ENV === 'development';
229
- }
230
-
231
- // ============================================================================
232
- // Instrumentation Helpers
233
- // ============================================================================
234
-
235
- /**
236
- * Middleware to log requests to DevTools
237
- */
238
- export function devToolsMiddleware() {
239
- return async (
240
- context: { request: Request },
241
- next: () => Promise<Response>
242
- ): Promise<Response> => {
243
- if (!devToolsInstance) return next();
244
-
245
- const start = performance.now();
246
- const { request } = context;
247
-
248
- try {
249
- const response = await next();
250
- const duration = performance.now() - start;
251
-
252
- devToolsInstance.logRequest({
253
- method: request.method,
254
- path: new URL(request.url).pathname,
255
- status: response.status,
256
- duration: Math.round(duration),
257
- });
258
-
259
- return response;
260
- } catch (error) {
261
- const duration = performance.now() - start;
262
-
263
- devToolsInstance.logRequest({
264
- method: request.method,
265
- path: new URL(request.url).pathname,
266
- status: 500,
267
- duration: Math.round(duration),
268
- });
269
-
270
- throw error;
271
- }
272
- };
273
- }
1
+ /**
2
+ * @flight-framework/devtools - Development Tools
3
+ *
4
+ * Provides debugging tools for Flight applications during development.
5
+ * Automatically disabled in production builds.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * // In your flight.config.ts or main entry
10
+ * import { enableDevTools } from '@flight-framework/devtools';
11
+ *
12
+ * if (process.env.NODE_ENV === 'development') {
13
+ * enableDevTools({
14
+ * port: 3001,
15
+ * showRoutes: true,
16
+ * showRequests: true,
17
+ * showCache: true,
18
+ * });
19
+ * }
20
+ * ```
21
+ */
22
+ // ============================================================================
23
+ // DevTools Manager
24
+ // ============================================================================
25
+ let devToolsInstance = null;
26
+ class DevToolsManager {
27
+ options;
28
+ state;
29
+ subscribers;
30
+ isEnabled;
31
+ constructor(options) {
32
+ this.options = {
33
+ port: options.port ?? 3001,
34
+ showRoutes: options.showRoutes ?? true,
35
+ showRequests: options.showRequests ?? true,
36
+ showCache: options.showCache ?? true,
37
+ showAdapters: options.showAdapters ?? true,
38
+ position: options.position ?? 'bottom-right',
39
+ };
40
+ this.state = {
41
+ routes: [],
42
+ requests: [],
43
+ cache: [],
44
+ adapters: [],
45
+ };
46
+ this.subscribers = new Set();
47
+ this.isEnabled = process.env.NODE_ENV === 'development';
48
+ }
49
+ /**
50
+ * Register routes for display in DevTools
51
+ */
52
+ registerRoutes(routes) {
53
+ if (!this.isEnabled)
54
+ return;
55
+ this.state.routes = routes;
56
+ this.notify();
57
+ }
58
+ /**
59
+ * Log a request
60
+ */
61
+ logRequest(info) {
62
+ if (!this.isEnabled || !this.options.showRequests)
63
+ return;
64
+ const request = {
65
+ ...info,
66
+ id: crypto.randomUUID(),
67
+ timestamp: Date.now(),
68
+ };
69
+ // Keep last 100 requests
70
+ this.state.requests = [request, ...this.state.requests].slice(0, 100);
71
+ this.notify();
72
+ }
73
+ /**
74
+ * Update cache info
75
+ */
76
+ updateCache(cache) {
77
+ if (!this.isEnabled || !this.options.showCache)
78
+ return;
79
+ this.state.cache = cache;
80
+ this.notify();
81
+ }
82
+ /**
83
+ * Register an adapter
84
+ */
85
+ registerAdapter(adapter) {
86
+ if (!this.isEnabled || !this.options.showAdapters)
87
+ return;
88
+ const existing = this.state.adapters.findIndex(a => a.name === adapter.name);
89
+ if (existing >= 0) {
90
+ this.state.adapters[existing] = adapter;
91
+ }
92
+ else {
93
+ this.state.adapters.push(adapter);
94
+ }
95
+ this.notify();
96
+ }
97
+ /**
98
+ * Subscribe to state changes
99
+ */
100
+ subscribe(callback) {
101
+ this.subscribers.add(callback);
102
+ callback(this.state); // Initial state
103
+ return () => this.subscribers.delete(callback);
104
+ }
105
+ /**
106
+ * Get current state
107
+ */
108
+ getState() {
109
+ return this.state;
110
+ }
111
+ /**
112
+ * Get options
113
+ */
114
+ getOptions() {
115
+ return this.options;
116
+ }
117
+ notify() {
118
+ for (const callback of this.subscribers) {
119
+ callback(this.state);
120
+ }
121
+ }
122
+ }
123
+ // ============================================================================
124
+ // Public API
125
+ // ============================================================================
126
+ /**
127
+ * Enable DevTools for the application
128
+ */
129
+ export function enableDevTools(options = {}) {
130
+ if (process.env.NODE_ENV !== 'development') {
131
+ console.warn('[Flight DevTools] DevTools are disabled in production');
132
+ return devToolsInstance;
133
+ }
134
+ if (!devToolsInstance) {
135
+ devToolsInstance = new DevToolsManager(options);
136
+ console.log(`[Flight DevTools] Enabled on port ${options.port ?? 3001}`);
137
+ }
138
+ return devToolsInstance;
139
+ }
140
+ /**
141
+ * Get the DevTools instance
142
+ */
143
+ export function getDevTools() {
144
+ return devToolsInstance;
145
+ }
146
+ /**
147
+ * Check if DevTools are enabled
148
+ */
149
+ export function isDevToolsEnabled() {
150
+ return devToolsInstance !== null && process.env.NODE_ENV === 'development';
151
+ }
152
+ // ============================================================================
153
+ // Instrumentation Helpers
154
+ // ============================================================================
155
+ /**
156
+ * Middleware to log requests to DevTools
157
+ */
158
+ export function devToolsMiddleware() {
159
+ return async (context, next) => {
160
+ if (!devToolsInstance)
161
+ return next();
162
+ const start = performance.now();
163
+ const { request } = context;
164
+ try {
165
+ const response = await next();
166
+ const duration = performance.now() - start;
167
+ devToolsInstance.logRequest({
168
+ method: request.method,
169
+ path: new URL(request.url).pathname,
170
+ status: response.status,
171
+ duration: Math.round(duration),
172
+ });
173
+ return response;
174
+ }
175
+ catch (error) {
176
+ const duration = performance.now() - start;
177
+ devToolsInstance.logRequest({
178
+ method: request.method,
179
+ path: new URL(request.url).pathname,
180
+ status: 500,
181
+ duration: Math.round(duration),
182
+ });
183
+ throw error;
184
+ }
185
+ };
186
+ }
187
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AA8DH,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E,IAAI,gBAAgB,GAA2B,IAAI,CAAC;AAEpD,MAAM,eAAe;IACT,OAAO,CAA4B;IACnC,KAAK,CAAgB;IACrB,WAAW,CAAsC;IACjD,SAAS,CAAU;IAE3B,YAAY,OAAwB;QAChC,IAAI,CAAC,OAAO,GAAG;YACX,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,IAAI;YAC1B,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,IAAI;YACtC,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,IAAI;YAC1C,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,IAAI;YACpC,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,IAAI;YAC1C,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,cAAc;SAC/C,CAAC;QAEF,IAAI,CAAC,KAAK,GAAG;YACT,MAAM,EAAE,EAAE;YACV,QAAQ,EAAE,EAAE;YACZ,KAAK,EAAE,EAAE;YACT,QAAQ,EAAE,EAAE;SACf,CAAC;QAEF,IAAI,CAAC,WAAW,GAAG,IAAI,GAAG,EAAE,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,CAAC;IAC5D,CAAC;I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AM,EAAE,GAAG;gBACX,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;aACjC,CAAC,CAAC;YAEH,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @flight-framework/devtools/instrumentation - Auto-instrumentation
3
+ *
4
+ * Automatically instruments Flight apps to send data to DevTools.
5
+ */
6
+ import { type AdapterInfo } from './index.js';
7
+ /**
8
+ * Instrument file router to report routes to DevTools
9
+ */
10
+ export declare function instrumentFileRouter(routes: unknown[]): void;
11
+ /**
12
+ * Instrument an adapter to report to DevTools
13
+ */
14
+ export declare function instrumentAdapter(adapter: {
15
+ name: string;
16
+ }, type: AdapterInfo['type']): void;
17
+ /**
18
+ * Report adapter error to DevTools
19
+ */
20
+ export declare function reportAdapterError(adapterName: string): void;
21
+ /**
22
+ * Instrument a cache to report to DevTools
23
+ */
24
+ export declare function instrumentCache(cache: Map<string, unknown>): void;
25
+ /**
26
+ * Auto-instrument common Flight patterns
27
+ * Call this once during app initialization
28
+ */
29
+ export declare function autoInstrument(): void;
30
+ //# sourceMappingURL=instrumentation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../src/instrumentation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAA+B,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAM3E;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAc5D;AAMD;;GAEG;AACH,wBAAgB,iBAAiB,CAC7B,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EACzB,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,GAC1B,IAAI,CASN;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAa5D;AAMD;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAYjE;AAMD;;;GAGG;AACH,wBAAgB,cAAc,IAAI,IAAI,CA8CrC"}
@@ -1,146 +1,126 @@
1
- /**
2
- * @flight-framework/devtools/instrumentation - Auto-instrumentation
3
- *
4
- * Automatically instruments Flight apps to send data to DevTools.
5
- */
6
-
7
- import { getDevTools, type RouteInfo, type AdapterInfo } from './index.js';
8
-
9
- // ============================================================================
10
- // Route Instrumentation
11
- // ============================================================================
12
-
13
- /**
14
- * Instrument file router to report routes to DevTools
15
- */
16
- export function instrumentFileRouter(routes: unknown[]): void {
17
- const devTools = getDevTools();
18
- if (!devTools) return;
19
-
20
- const routeInfos: RouteInfo[] = (routes as any[]).map(route => ({
21
- method: route.method || 'GET',
22
- path: route.path || '/',
23
- type: route.type || 'page',
24
- filePath: route.filePath || '',
25
- slot: route.slot,
26
- interceptInfo: route.interceptInfo,
27
- }));
28
-
29
- devTools.registerRoutes(routeInfos);
30
- }
31
-
32
- // ============================================================================
33
- // Adapter Instrumentation
34
- // ============================================================================
35
-
36
- /**
37
- * Instrument an adapter to report to DevTools
38
- */
39
- export function instrumentAdapter(
40
- adapter: { name: string },
41
- type: AdapterInfo['type']
42
- ): void {
43
- const devTools = getDevTools();
44
- if (!devTools) return;
45
-
46
- devTools.registerAdapter({
47
- name: adapter.name,
48
- type,
49
- status: 'connected',
50
- });
51
- }
52
-
53
- /**
54
- * Report adapter error to DevTools
55
- */
56
- export function reportAdapterError(adapterName: string): void {
57
- const devTools = getDevTools();
58
- if (!devTools) return;
59
-
60
- const state = devTools.getState();
61
- const adapter = state.adapters.find(a => a.name === adapterName);
62
-
63
- if (adapter) {
64
- devTools.registerAdapter({
65
- ...adapter,
66
- status: 'error',
67
- });
68
- }
69
- }
70
-
71
- // ============================================================================
72
- // Cache Instrumentation
73
- // ============================================================================
74
-
75
- /**
76
- * Instrument a cache to report to DevTools
77
- */
78
- export function instrumentCache(cache: Map<string, unknown>): void {
79
- const devTools = getDevTools();
80
- if (!devTools) return;
81
-
82
- const cacheInfos = Array.from(cache.entries()).map(([key, value]) => ({
83
- key,
84
- size: JSON.stringify(value).length,
85
- hits: 0,
86
- lastAccessed: Date.now(),
87
- }));
88
-
89
- devTools.updateCache(cacheInfos);
90
- }
91
-
92
- // ============================================================================
93
- // Auto-Instrumentation
94
- // ============================================================================
95
-
96
- /**
97
- * Auto-instrument common Flight patterns
98
- * Call this once during app initialization
99
- */
100
- export function autoInstrument(): void {
101
- if (process.env.NODE_ENV !== 'development') return;
102
-
103
- console.log('[Flight DevTools] Auto-instrumentation enabled');
104
-
105
- // Instrument fetch for request logging
106
- if (typeof globalThis.fetch !== 'undefined') {
107
- const originalFetch = globalThis.fetch;
108
-
109
- globalThis.fetch = async (input, init) => {
110
- const devTools = getDevTools();
111
- const start = performance.now();
112
-
113
- try {
114
- const response = await originalFetch(input, init);
115
-
116
- if (devTools) {
117
- const url = typeof input === 'string'
118
- ? input
119
- : input instanceof URL
120
- ? input.pathname
121
- : (input as Request).url;
122
-
123
- devTools.logRequest({
124
- method: init?.method || 'GET',
125
- path: new URL(url, 'http://localhost').pathname,
126
- status: response.status,
127
- duration: Math.round(performance.now() - start),
128
- });
129
- }
130
-
131
- return response;
132
- } catch (error) {
133
- if (devTools) {
134
- const url = typeof input === 'string' ? input : (input as Request)?.url || '/';
135
- devTools.logRequest({
136
- method: init?.method || 'GET',
137
- path: new URL(url, 'http://localhost').pathname,
138
- status: 0,
139
- duration: Math.round(performance.now() - start),
140
- });
141
- }
142
- throw error;
143
- }
144
- };
145
- }
146
- }
1
+ /**
2
+ * @flight-framework/devtools/instrumentation - Auto-instrumentation
3
+ *
4
+ * Automatically instruments Flight apps to send data to DevTools.
5
+ */
6
+ import { getDevTools } from './index.js';
7
+ // ============================================================================
8
+ // Route Instrumentation
9
+ // ============================================================================
10
+ /**
11
+ * Instrument file router to report routes to DevTools
12
+ */
13
+ export function instrumentFileRouter(routes) {
14
+ const devTools = getDevTools();
15
+ if (!devTools)
16
+ return;
17
+ const routeInfos = routes.map(route => ({
18
+ method: route.method || 'GET',
19
+ path: route.path || '/',
20
+ type: route.type || 'page',
21
+ filePath: route.filePath || '',
22
+ slot: route.slot,
23
+ interceptInfo: route.interceptInfo,
24
+ }));
25
+ devTools.registerRoutes(routeInfos);
26
+ }
27
+ // ============================================================================
28
+ // Adapter Instrumentation
29
+ // ============================================================================
30
+ /**
31
+ * Instrument an adapter to report to DevTools
32
+ */
33
+ export function instrumentAdapter(adapter, type) {
34
+ const devTools = getDevTools();
35
+ if (!devTools)
36
+ return;
37
+ devTools.registerAdapter({
38
+ name: adapter.name,
39
+ type,
40
+ status: 'connected',
41
+ });
42
+ }
43
+ /**
44
+ * Report adapter error to DevTools
45
+ */
46
+ export function reportAdapterError(adapterName) {
47
+ const devTools = getDevTools();
48
+ if (!devTools)
49
+ return;
50
+ const state = devTools.getState();
51
+ const adapter = state.adapters.find(a => a.name === adapterName);
52
+ if (adapter) {
53
+ devTools.registerAdapter({
54
+ ...adapter,
55
+ status: 'error',
56
+ });
57
+ }
58
+ }
59
+ // ============================================================================
60
+ // Cache Instrumentation
61
+ // ============================================================================
62
+ /**
63
+ * Instrument a cache to report to DevTools
64
+ */
65
+ export function instrumentCache(cache) {
66
+ const devTools = getDevTools();
67
+ if (!devTools)
68
+ return;
69
+ const cacheInfos = Array.from(cache.entries()).map(([key, value]) => ({
70
+ key,
71
+ size: JSON.stringify(value).length,
72
+ hits: 0,
73
+ lastAccessed: Date.now(),
74
+ }));
75
+ devTools.updateCache(cacheInfos);
76
+ }
77
+ // ============================================================================
78
+ // Auto-Instrumentation
79
+ // ============================================================================
80
+ /**
81
+ * Auto-instrument common Flight patterns
82
+ * Call this once during app initialization
83
+ */
84
+ export function autoInstrument() {
85
+ if (process.env.NODE_ENV !== 'development')
86
+ return;
87
+ console.log('[Flight DevTools] Auto-instrumentation enabled');
88
+ // Instrument fetch for request logging
89
+ if (typeof globalThis.fetch !== 'undefined') {
90
+ const originalFetch = globalThis.fetch;
91
+ globalThis.fetch = async (input, init) => {
92
+ const devTools = getDevTools();
93
+ const start = performance.now();
94
+ try {
95
+ const response = await originalFetch(input, init);
96
+ if (devTools) {
97
+ const url = typeof input === 'string'
98
+ ? input
99
+ : input instanceof URL
100
+ ? input.pathname
101
+ : input.url;
102
+ devTools.logRequest({
103
+ method: init?.method || 'GET',
104
+ path: new URL(url, 'http://localhost').pathname,
105
+ status: response.status,
106
+ duration: Math.round(performance.now() - start),
107
+ });
108
+ }
109
+ return response;
110
+ }
111
+ catch (error) {
112
+ if (devTools) {
113
+ const url = typeof input === 'string' ? input : input?.url || '/';
114
+ devTools.logRequest({
115
+ method: init?.method || 'GET',
116
+ path: new URL(url, 'http://localhost').pathname,
117
+ status: 0,
118
+ duration: Math.round(performance.now() - start),
119
+ });
120
+ }
121
+ throw error;
122
+ }
123
+ };
124
+ }
125
+ }
126
+ //# sourceMappingURL=instrumentation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../src/instrumentation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAoC,MAAM,YAAY,CAAC;AAE3E,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAiB;IAClD,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAC/B,IAAI,CAAC,QAAQ;QAAE,OAAO;IAEtB,MAAM,UAAU,GAAiB,MAAgB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC5D,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,KAAK;QAC7B,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,GAAG;QACvB,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,MAAM;QAC1B,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,EAA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,kBAAkB,CAAC,CAAC,QAAQ;wBAC/C,MAAM,EAAE,QAAQ,CAAC,MAAM;wBACvB,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;qBAClD,CAAC,CAAC;gBACP,CAAC;gBAED,OAAO,QAAQ,CAAC;YACpB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,IAAI,QAAQ,EAAE,CAAC;oBACX,MAAM,GAAG,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAE,KAAiB,EAAE,GAAG,IAAI,GAAG,CAAC;oBAC/E,QAAQ,CAAC,UAAU,CAAC;wBAChB,MAAM,EAAE,IAAI,EAAE,MAAM,IAAI,KAAK;wBAC7B,IAAI,EAAE,IAAI,GAAG,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC,QAAQ;wBAC/C,MAAM,EAAE,CAAC;wBACT,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;qBAClD,CAAC,CAAC;gBACP,CAAC;gBACD,MAAM,KAAK,CAAC;YAChB,CAAC;QACL,CAAC,CAAC;IACN,CAAC;AACL,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @flight-framework/devtools/panel - DevTools Panel UI
3
+ *
4
+ * React component for the DevTools floating panel.
5
+ * Automatically injected into pages during development.
6
+ */
7
+ /**
8
+ * Inject the DevTools panel into the page
9
+ * Call this in your app's entry point during development
10
+ */
11
+ export declare function injectDevToolsPanel(): void;
12
+ //# sourceMappingURL=panel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panel.d.ts","sourceRoot":"","sources":["../src/panel.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAmI1C"}
@@ -1,43 +1,36 @@
1
- /**
2
- * @flight-framework/devtools/panel - DevTools Panel UI
3
- *
4
- * React component for the DevTools floating panel.
5
- * Automatically injected into pages during development.
6
- */
7
-
8
- import { getDevTools, type DevToolsState, type RouteInfo, type RequestInfo } from './index.js';
9
-
10
- // ============================================================================
11
- // Panel Component (Plain JS for framework-agnostic use)
12
- // ============================================================================
13
-
14
- /**
15
- * Inject the DevTools panel into the page
16
- * Call this in your app's entry point during development
17
- */
18
- export function injectDevToolsPanel(): void {
19
- if (typeof document === 'undefined') return;
20
-
21
- const devTools = getDevTools();
22
- if (!devTools) return;
23
-
24
- // Create container
25
- const container = document.createElement('div');
26
- container.id = 'flight-devtools';
27
- document.body.appendChild(container);
28
-
29
- // Inject styles
30
- const styles = document.createElement('style');
31
- styles.textContent = getDevToolsStyles();
32
- document.head.appendChild(styles);
33
-
34
- // Initial render
35
- let isOpen = false;
36
- let currentTab = 'routes';
37
-
38
- function render(state: DevToolsState): void {
39
- const options = devTools!.getOptions();
40
-
1
+ /**
2
+ * @flight-framework/devtools/panel - DevTools Panel UI
3
+ *
4
+ * React component for the DevTools floating panel.
5
+ * Automatically injected into pages during development.
6
+ */
7
+ import { getDevTools } from './index.js';
8
+ // ============================================================================
9
+ // Panel Component (Plain JS for framework-agnostic use)
10
+ // ============================================================================
11
+ /**
12
+ * Inject the DevTools panel into the page
13
+ * Call this in your app's entry point during development
14
+ */
15
+ export function injectDevToolsPanel() {
16
+ if (typeof document === 'undefined')
17
+ return;
18
+ const devTools = getDevTools();
19
+ if (!devTools)
20
+ return;
21
+ // Create container
22
+ const container = document.createElement('div');
23
+ container.id = 'flight-devtools';
24
+ document.body.appendChild(container);
25
+ // Inject styles
26
+ const styles = document.createElement('style');
27
+ styles.textContent = getDevToolsStyles();
28
+ document.head.appendChild(styles);
29
+ // Initial render
30
+ let isOpen = false;
31
+ let currentTab = 'routes';
32
+ function render(state) {
33
+ const options = devTools.getOptions();
41
34
  container.innerHTML = `
42
35
  <div class="flight-devtools ${options.position} ${isOpen ? 'open' : ''}">
43
36
  <button class="flight-devtools-toggle" onclick="window.__flightToggleDevTools()">
@@ -45,10 +38,9 @@ export function injectDevToolsPanel(): void {
45
38
  </button>
46
39
  ${isOpen ? renderPanel(state, currentTab) : ''}
47
40
  </div>
48
- `;
49
- }
50
-
51
- function renderPanel(state: DevToolsState, tab: string): string {
41
+ `;
42
+ }
43
+ function renderPanel(state, tab) {
52
44
  return `
53
45
  <div class="flight-devtools-panel">
54
46
  <div class="flight-devtools-header">
@@ -71,16 +63,13 @@ export function injectDevToolsPanel(): void {
71
63
  ${tab === 'adapters' ? renderAdapters(state) : ''}
72
64
  </div>
73
65
  </div>
74
- `;
75
- }
76
-
77
- function renderRoutes(routes: RouteInfo[]): string {
78
- if (routes.length === 0) {
79
- return '<div class="flight-devtools-empty">No routes registered</div>';
80
- }
81
-
82
- const dots = (level: number) => '.'.repeat(level);
83
-
66
+ `;
67
+ }
68
+ function renderRoutes(routes) {
69
+ if (routes.length === 0) {
70
+ return '<div class="flight-devtools-empty">No routes registered</div>';
71
+ }
72
+ const dots = (level) => '.'.repeat(level);
84
73
  return `
85
74
  <div class="flight-devtools-list">
86
75
  ${routes.map(route => `
@@ -93,14 +82,12 @@ export function injectDevToolsPanel(): void {
93
82
  </div>
94
83
  `).join('')}
95
84
  </div>
96
- `;
97
- }
98
-
99
- function renderRequests(requests: RequestInfo[]): string {
100
- if (requests.length === 0) {
101
- return '<div class="flight-devtools-empty">No requests yet</div>';
102
- }
103
-
85
+ `;
86
+ }
87
+ function renderRequests(requests) {
88
+ if (requests.length === 0) {
89
+ return '<div class="flight-devtools-empty">No requests yet</div>';
90
+ }
104
91
  return `
105
92
  <div class="flight-devtools-list">
106
93
  ${requests.slice(0, 20).map(req => `
@@ -112,14 +99,12 @@ export function injectDevToolsPanel(): void {
112
99
  </div>
113
100
  `).join('')}
114
101
  </div>
115
- `;
116
- }
117
-
118
- function renderAdapters(state: DevToolsState): string {
119
- if (state.adapters.length === 0) {
120
- return '<div class="flight-devtools-empty">No adapters registered</div>';
121
- }
122
-
102
+ `;
103
+ }
104
+ function renderAdapters(state) {
105
+ if (state.adapters.length === 0) {
106
+ return '<div class="flight-devtools-empty">No adapters registered</div>';
107
+ }
123
108
  return `
124
109
  <div class="flight-devtools-list">
125
110
  ${state.adapters.map(adapter => `
@@ -130,29 +115,24 @@ export function injectDevToolsPanel(): void {
130
115
  </div>
131
116
  `).join('')}
132
117
  </div>
133
- `;
134
- }
135
-
136
- // Global functions for onclick handlers
137
- (window as any).__flightToggleDevTools = () => {
138
- isOpen = !isOpen;
139
- render(devTools!.getState());
140
- };
141
-
142
- (window as any).__flightSetTab = (tab: string) => {
143
- currentTab = tab;
144
- render(devTools!.getState());
145
- };
146
-
147
- // Subscribe to state changes
148
- devTools.subscribe(render);
149
- }
150
-
151
- // ============================================================================
152
- // Styles
153
- // ============================================================================
154
-
155
- function getDevToolsStyles(): string {
118
+ `;
119
+ }
120
+ // Global functions for onclick handlers
121
+ window.__flightToggleDevTools = () => {
122
+ isOpen = !isOpen;
123
+ render(devTools.getState());
124
+ };
125
+ window.__flightSetTab = (tab) => {
126
+ currentTab = tab;
127
+ render(devTools.getState());
128
+ };
129
+ // Subscribe to state changes
130
+ devTools.subscribe(render);
131
+ }
132
+ // ============================================================================
133
+ // Styles
134
+ // ============================================================================
135
+ function getDevToolsStyles() {
156
136
  return `
157
137
  #flight-devtools {
158
138
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
@@ -284,5 +264,6 @@ function getDevToolsStyles(): string {
284
264
  text-align: center;
285
265
  color: #666;
286
266
  }
287
- `;
288
- }
267
+ `;
268
+ }
269
+ //# sourceMappingURL=panel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panel.js","sourceRoot":"","sources":["../src/panel.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAwD,MAAM,YAAY,CAAC;AAE/F,+EAA+E;AAC/E,wDAAwD;AACxD,+EAA+E;AAE/E;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,CAAC;IAEF,6BAA6B;IAC7B,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC;AAED,+EAA+E;AAC/E,SAAS;AACT,+EAA+E;AAE/E,SAAS,iBAAiB;IACtB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAmIN,CAAC;AACN,CAAC"}
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@flight-framework/devtools",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Development tools and debugging panel for Flight Framework",
5
5
  "type": "module",
6
+ "files": [
7
+ "dist"
8
+ ],
6
9
  "main": "./dist/index.js",
7
10
  "types": "./dist/index.d.ts",
8
11
  "exports": {
package/tsconfig.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "./dist",
5
- "rootDir": "./src",
6
- "declaration": true,
7
- "declarationMap": true,
8
- "jsx": "react-jsx"
9
- },
10
- "include": [
11
- "src/**/*"
12
- ],
13
- "exclude": [
14
- "node_modules",
15
- "dist"
16
- ]
17
- }