@getlimelight/sdk 0.5.5 โ 0.7.4
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/README.md +50 -13
- package/dist/index.d.mts +104 -27
- package/dist/index.d.ts +104 -27
- package/dist/index.js +383 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +383 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Limelight SDK
|
|
2
2
|
|
|
3
|
-
> **
|
|
3
|
+
> **React Native Devtools** - Zero-config network inspector, render profiling, state tracking, and console streaming โ
|
|
4
|
+
> all in one workspace. Designed for AI workflows.
|
|
4
5
|
|
|
5
6
|
[](https://www.npmjs.com/package/@getlimelight/sdk)
|
|
6
7
|
[](https://opensource.org/licenses/MIT)
|
|
@@ -8,16 +9,24 @@
|
|
|
8
9
|
|
|
9
10
|
## Documentation
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
**Full documentation at [docs.getlimelight.io](https://docs.getlimelight.io)**
|
|
13
|
+
|
|
14
|
+
## Landing page
|
|
15
|
+
|
|
16
|
+
**Landing page at [getlimelight.io](https://getlimelight.io)**
|
|
12
17
|
|
|
13
18
|
## Features
|
|
14
19
|
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
20
|
+
- **State Inspection** - Debug Zustand and Redux stores in real-time
|
|
21
|
+
- **Network Monitoring** - Inspect all HTTP requests with GraphQL-first support
|
|
22
|
+
- **Console Streaming** - View logs with stack traces and source detection
|
|
23
|
+
- **Render Tracking** - Find why components re-render
|
|
24
|
+
- **Privacy-First** - Automatic redaction of sensitive data
|
|
25
|
+
- **Zero Config** - Works out of the box
|
|
26
|
+
- **Framework Agnostic** - Work in React, RN, Node, Nextjs, etc...
|
|
27
|
+
- **Full-Stack** - See client to server requests traced together and full-stack logs in one place
|
|
28
|
+
- **Automatic Issue Detection** - Limelight automatically detects issues in your app and server
|
|
29
|
+
- **AI Enabled** - Give your AI coding tools insights into your apps runtime context via the Limelight MCP or thorugh the app
|
|
21
30
|
|
|
22
31
|
## Installation
|
|
23
32
|
|
|
@@ -90,14 +99,42 @@ Limelight.connect({
|
|
|
90
99
|
});
|
|
91
100
|
```
|
|
92
101
|
|
|
102
|
+
### Server-Side (Express / Next.js)
|
|
103
|
+
|
|
104
|
+
Capture incoming HTTP requests and responses on your backend.
|
|
105
|
+
|
|
106
|
+
**Express / Connect:**
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
import express from "express";
|
|
110
|
+
import { Limelight } from "@getlimelight/sdk";
|
|
111
|
+
|
|
112
|
+
const app = express();
|
|
113
|
+
|
|
114
|
+
app.use(express.json());
|
|
115
|
+
app.use(Limelight.middleware());
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**Next.js Pages Router (`pages/api/`):**
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
// pages/api/users.ts
|
|
122
|
+
import { Limelight } from "@getlimelight/sdk";
|
|
123
|
+
|
|
124
|
+
export default Limelight.withLimelight((req, res) => {
|
|
125
|
+
res.json({ ok: true });
|
|
126
|
+
});
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Both methods automatically capture request/response headers, bodies, status codes, and timing โ and propagate a trace ID (`x-limelight-trace-id`) for full-stack tracing.
|
|
130
|
+
|
|
93
131
|
## Learn More
|
|
94
132
|
|
|
95
133
|
- [Quick Start Guide](https://docs.getlimelight.io/quickstart)
|
|
96
134
|
- [State Inspection](https://docs.getlimelight.io/features/state)
|
|
97
|
-
- [Network Monitoring](https://docs.getlimelight.io/features/network)
|
|
98
|
-
- [Console Streaming](https://docs.getlimelight.io/features/console)
|
|
99
|
-
- [Render Tracking](https://docs.getlimelight.io/features/
|
|
100
|
-
- [Configuration Reference](https://docs.getlimelight.io/configuration)
|
|
135
|
+
- [Network Monitoring](https://docs.getlimelight.io/features/network-requests)
|
|
136
|
+
- [Console Streaming](https://docs.getlimelight.io/features/console-logs)
|
|
137
|
+
- [Render Tracking](https://docs.getlimelight.io/features/render-tracking)
|
|
101
138
|
|
|
102
139
|
## License
|
|
103
140
|
|
|
@@ -105,4 +142,4 @@ MIT ยฉ Limelight
|
|
|
105
142
|
|
|
106
143
|
---
|
|
107
144
|
|
|
108
|
-
[Documentation](https://docs.getlimelight.io) ยท [GitHub](https://github.com/getlimelight/limelight) ยท [Issues](https://github.com/getlimelight/limelight/issues)
|
|
145
|
+
[Documentation](https://docs.getlimelight.io) ยท [GitHub](https://github.com/getlimelight/limelight-sdk) ยท [Issues](https://github.com/getlimelight/limelight-sdk/issues)
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import * as http from 'http';
|
|
2
|
+
import { IncomingMessage, ServerResponse } from 'http';
|
|
3
|
+
|
|
1
4
|
declare enum NetworkType {
|
|
2
5
|
FETCH = "fetch",
|
|
3
6
|
XHR = "xhr",
|
|
4
|
-
GRAPHQL = "graphql"
|
|
7
|
+
GRAPHQL = "graphql",
|
|
8
|
+
INCOMING = "incoming"
|
|
5
9
|
}
|
|
6
10
|
declare enum NetworkPhase {
|
|
7
11
|
CONNECT = "CONNECT",
|
|
@@ -51,6 +55,7 @@ interface SerializedBody {
|
|
|
51
55
|
*/
|
|
52
56
|
interface BaseNetworkEvent {
|
|
53
57
|
id: string;
|
|
58
|
+
traceId?: string;
|
|
54
59
|
sessionId: string;
|
|
55
60
|
timestamp: number;
|
|
56
61
|
phase: NetworkPhase;
|
|
@@ -109,6 +114,9 @@ interface ConnectEvent {
|
|
|
109
114
|
platform: "ios" | "android";
|
|
110
115
|
};
|
|
111
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Request with its corresponding response (for UI display)
|
|
119
|
+
*/
|
|
112
120
|
declare enum EventType {
|
|
113
121
|
NETWORK = "NETWORK",
|
|
114
122
|
CONSOLE = "CONSOLE"
|
|
@@ -118,29 +126,6 @@ declare enum EventType {
|
|
|
118
126
|
*/
|
|
119
127
|
type NetworkEvent = ConnectEvent | NetworkRequest | NetworkResponse | NetworkErrorEvent | GraphQLRequest | GraphQLResponse;
|
|
120
128
|
type LimelightEvent = NetworkEvent | ConsoleEvent;
|
|
121
|
-
interface Session {
|
|
122
|
-
id: string;
|
|
123
|
-
appName: string;
|
|
124
|
-
platform: "ios" | "android";
|
|
125
|
-
connectedAt: number;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Request with its corresponding response (for UI display)
|
|
129
|
-
*/
|
|
130
|
-
interface NetworkRequestWithResponse extends NetworkRequest {
|
|
131
|
-
response?: NetworkResponse;
|
|
132
|
-
status?: number;
|
|
133
|
-
duration?: number;
|
|
134
|
-
error?: NetworkErrorEvent;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Request with its corresponding response (for UI display)
|
|
138
|
-
*/
|
|
139
|
-
interface NetworkRequestWithResponse extends NetworkRequest {
|
|
140
|
-
response?: NetworkResponse;
|
|
141
|
-
status?: number;
|
|
142
|
-
duration?: number;
|
|
143
|
-
}
|
|
144
129
|
|
|
145
130
|
/**
|
|
146
131
|
* Console log levels
|
|
@@ -398,9 +383,9 @@ interface LimelightConfig {
|
|
|
398
383
|
*/
|
|
399
384
|
projectKey?: string;
|
|
400
385
|
/**
|
|
401
|
-
* The platform of the application
|
|
386
|
+
* The platform of the application. Auto-detected if not provided.
|
|
402
387
|
*/
|
|
403
|
-
platform?: string;
|
|
388
|
+
platform?: "ios" | "android" | "web" | "react-native" | "node" | (string & {});
|
|
404
389
|
/**
|
|
405
390
|
* The URL of the Limelight server to connect to. If not provided, it falls back to the local wss server url if there is no project key, or the web wss url if there is a project key.
|
|
406
391
|
*/
|
|
@@ -411,26 +396,32 @@ interface LimelightConfig {
|
|
|
411
396
|
appName?: string;
|
|
412
397
|
/**
|
|
413
398
|
* Flag to enable or disable the Limelight SDK.
|
|
399
|
+
* @default true (SDK is enabled by default)
|
|
414
400
|
*/
|
|
415
401
|
enabled?: boolean;
|
|
416
402
|
/**
|
|
417
403
|
* Flag to enable or disable network request inspection.
|
|
404
|
+
* @default true
|
|
418
405
|
*/
|
|
419
406
|
enableNetworkInspector?: boolean;
|
|
420
407
|
/**
|
|
421
408
|
* Flag to enable or disable console event capturing.
|
|
409
|
+
* @default true
|
|
422
410
|
*/
|
|
423
411
|
enableConsole?: boolean;
|
|
424
412
|
/**
|
|
425
413
|
* Flag to enable or disable GraphQL request capturing.
|
|
414
|
+
* @default true
|
|
426
415
|
*/
|
|
427
416
|
enableGraphQL?: boolean;
|
|
428
417
|
/**
|
|
429
418
|
* Flag to disable capturing of request and response bodies.
|
|
419
|
+
* @default false (bodies are captured by default)
|
|
430
420
|
*/
|
|
431
421
|
disableBodyCapture?: boolean;
|
|
432
422
|
/**
|
|
433
423
|
* Flag to enable or disable render inspection.
|
|
424
|
+
* @default true
|
|
434
425
|
*/
|
|
435
426
|
enableRenderInspector?: boolean;
|
|
436
427
|
/**
|
|
@@ -445,12 +436,30 @@ interface LimelightConfig {
|
|
|
445
436
|
enableStateInspector?: boolean;
|
|
446
437
|
/**
|
|
447
438
|
* Flag to enable or disable internal logging for the Limelight SDK
|
|
439
|
+
* @default false
|
|
448
440
|
*/
|
|
449
441
|
enableInternalLogging?: boolean;
|
|
442
|
+
/**
|
|
443
|
+
* Target destination for events. Set to "mcp" to send events to the MCP server at ws://localhost:9229.
|
|
444
|
+
*/
|
|
445
|
+
target?: "mcp";
|
|
446
|
+
/**
|
|
447
|
+
* Custom header name used for trace ID propagation across client and server.
|
|
448
|
+
* @default 'x-limelight-trace-id'
|
|
449
|
+
*/
|
|
450
|
+
traceHeaderName?: string;
|
|
450
451
|
/**
|
|
451
452
|
* A callback function to modify or filter events before they are sent to the server
|
|
452
453
|
*/
|
|
453
454
|
beforeSend?: (event: LimelightMessage) => LimelightMessage | null;
|
|
455
|
+
/**
|
|
456
|
+
* Custom WebSocket implementation for Node.js environments where WebSocket
|
|
457
|
+
* is not globally available (Node < 22). Pass the `ws` package constructor.
|
|
458
|
+
* @example
|
|
459
|
+
* import WebSocket from 'ws';
|
|
460
|
+
* Limelight.connect({ webSocketImpl: WebSocket });
|
|
461
|
+
*/
|
|
462
|
+
webSocketImpl?: new (url: string, protocols?: string | string[]) => WebSocket;
|
|
454
463
|
}
|
|
455
464
|
/**
|
|
456
465
|
* Represents a connection or disconnection event in the Limelight SDK.
|
|
@@ -516,6 +525,41 @@ interface ResponseBridgeConfig {
|
|
|
516
525
|
body?: any;
|
|
517
526
|
}
|
|
518
527
|
|
|
528
|
+
interface MiddlewareOptions {
|
|
529
|
+
/** Maximum body size to capture in bytes. Bodies larger than this are truncated. Default: 64KB */
|
|
530
|
+
maxBodySize?: number;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
type NextApiHandler = (req: IncomingMessage & {
|
|
534
|
+
body?: unknown;
|
|
535
|
+
query?: Record<string, unknown>;
|
|
536
|
+
}, res: ServerResponse) => void | Promise<void>;
|
|
537
|
+
/**
|
|
538
|
+
* Wraps a Next.js Pages API route handler with Limelight request/response capture.
|
|
539
|
+
*
|
|
540
|
+
* NOTE: This works with Next.js Pages Router API routes (`pages/api/`)
|
|
541
|
+
* which use the Node.js `(req, res)` signature. It does NOT work with
|
|
542
|
+
* App Router route handlers (`app/api/`) which use the Web Standard
|
|
543
|
+
* `Request`/`Response` objects. App Router support is planned for a future release.
|
|
544
|
+
*
|
|
545
|
+
* @example
|
|
546
|
+
* ```ts
|
|
547
|
+
* // pages/api/users.ts
|
|
548
|
+
* import { Limelight } from '@getlimelight/sdk';
|
|
549
|
+
*
|
|
550
|
+
* export default Limelight.withLimelight((req, res) => {
|
|
551
|
+
* res.json({ ok: true });
|
|
552
|
+
* });
|
|
553
|
+
* ```
|
|
554
|
+
*
|
|
555
|
+
* @param sendMessage Function to send Limelight messages to the server
|
|
556
|
+
* @param getSessionId Function to retrieve the current Limelight session ID
|
|
557
|
+
* @param getConfig Function to retrieve the current Limelight configuration
|
|
558
|
+
* @param options Optional middleware options (e.g. maxBodySize)
|
|
559
|
+
* @returns A function that wraps a Next.js API route handler with Limelight capture
|
|
560
|
+
*/
|
|
561
|
+
declare const createWithLimelight: (sendMessage: (message: LimelightMessage) => void, getSessionId: () => string, getConfig: () => LimelightConfig | null, options?: MiddlewareOptions) => (handler: NextApiHandler) => NextApiHandler;
|
|
562
|
+
|
|
519
563
|
declare class LimelightClient {
|
|
520
564
|
private ws;
|
|
521
565
|
private config;
|
|
@@ -531,6 +575,7 @@ declare class LimelightClient {
|
|
|
531
575
|
private consoleInterceptor;
|
|
532
576
|
private renderInterceptor;
|
|
533
577
|
private stateInterceptor;
|
|
578
|
+
private errorInterceptor;
|
|
534
579
|
private requestBridge;
|
|
535
580
|
private commandHandler;
|
|
536
581
|
constructor();
|
|
@@ -616,6 +661,37 @@ declare class LimelightClient {
|
|
|
616
661
|
* @param error - The error that occurred
|
|
617
662
|
*/
|
|
618
663
|
failRequest(requestId: string, error: unknown): void;
|
|
664
|
+
/**
|
|
665
|
+
* Returns an Express/Connect-compatible middleware that captures incoming
|
|
666
|
+
* HTTP requests and responses.
|
|
667
|
+
*
|
|
668
|
+
* Place after body-parser middleware (express.json(), etc.) for request body capture.
|
|
669
|
+
*
|
|
670
|
+
* @example
|
|
671
|
+
* ```ts
|
|
672
|
+
* app.use(express.json());
|
|
673
|
+
* app.use(Limelight.middleware());
|
|
674
|
+
* ```
|
|
675
|
+
*/
|
|
676
|
+
middleware(options?: MiddlewareOptions): (req: http.IncomingMessage & {
|
|
677
|
+
body?: unknown;
|
|
678
|
+
}, res: http.ServerResponse, next: () => void) => void;
|
|
679
|
+
/**
|
|
680
|
+
* Wraps a Next.js Pages API route handler with request/response capture.
|
|
681
|
+
* Works with Pages Router (`pages/api/`), not App Router (`app/api/`).
|
|
682
|
+
*
|
|
683
|
+
* @example
|
|
684
|
+
* ```ts
|
|
685
|
+
* // pages/api/users.ts
|
|
686
|
+
* export default Limelight.withLimelight((req, res) => {
|
|
687
|
+
* res.json({ ok: true });
|
|
688
|
+
* });
|
|
689
|
+
* ```
|
|
690
|
+
*/
|
|
691
|
+
withLimelight(handler: Parameters<ReturnType<typeof createWithLimelight>>[0]): (req: http.IncomingMessage & {
|
|
692
|
+
body?: unknown;
|
|
693
|
+
query?: Record<string, unknown>;
|
|
694
|
+
}, res: http.ServerResponse) => void | Promise<void>;
|
|
619
695
|
}
|
|
620
696
|
declare const Limelight: LimelightClient;
|
|
621
697
|
|
|
@@ -623,6 +699,7 @@ declare global {
|
|
|
623
699
|
interface XMLHttpRequest {
|
|
624
700
|
_limelightData?: {
|
|
625
701
|
id: string;
|
|
702
|
+
traceId?: string;
|
|
626
703
|
method: string;
|
|
627
704
|
url: string;
|
|
628
705
|
headers: Record<string, string>;
|
|
@@ -633,4 +710,4 @@ declare global {
|
|
|
633
710
|
}
|
|
634
711
|
}
|
|
635
712
|
|
|
636
|
-
export { type BaseCommand, type BaseNetworkEvent, BodyFormat, type ClearRendersCommand, type Command, type CommandAckEvent, CommandType, type ConnectEvent, type ConnectionEvent, type ConsoleEvent, ConsoleLevel, ConsoleSource, ConsoleType, EventType, type GraphQLRequest, type GraphQLResponse, GraphqlOprtation, HttpMethod, HttpStatusClass, Limelight, type LimelightConfig, type LimelightEvent, type LimelightMessage, type NetworkErrorEvent, type NetworkEvent, NetworkPhase, type NetworkRequest, type
|
|
713
|
+
export { type BaseCommand, type BaseNetworkEvent, BodyFormat, type ClearRendersCommand, type Command, type CommandAckEvent, CommandType, type ConnectEvent, type ConnectionEvent, type ConsoleEvent, ConsoleLevel, ConsoleSource, ConsoleType, EventType, type GraphQLRequest, type GraphQLResponse, GraphqlOprtation, HttpMethod, HttpStatusClass, Limelight, type LimelightConfig, type LimelightEvent, type LimelightMessage, type NetworkErrorEvent, type NetworkEvent, NetworkPhase, type NetworkRequest, type NetworkResponse, NetworkType, type ParsedStackTrace, type RequestBridgeConfig, type ResponseBridgeConfig, type SerializedBody, type StackFrame };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import * as http from 'http';
|
|
2
|
+
import { IncomingMessage, ServerResponse } from 'http';
|
|
3
|
+
|
|
1
4
|
declare enum NetworkType {
|
|
2
5
|
FETCH = "fetch",
|
|
3
6
|
XHR = "xhr",
|
|
4
|
-
GRAPHQL = "graphql"
|
|
7
|
+
GRAPHQL = "graphql",
|
|
8
|
+
INCOMING = "incoming"
|
|
5
9
|
}
|
|
6
10
|
declare enum NetworkPhase {
|
|
7
11
|
CONNECT = "CONNECT",
|
|
@@ -51,6 +55,7 @@ interface SerializedBody {
|
|
|
51
55
|
*/
|
|
52
56
|
interface BaseNetworkEvent {
|
|
53
57
|
id: string;
|
|
58
|
+
traceId?: string;
|
|
54
59
|
sessionId: string;
|
|
55
60
|
timestamp: number;
|
|
56
61
|
phase: NetworkPhase;
|
|
@@ -109,6 +114,9 @@ interface ConnectEvent {
|
|
|
109
114
|
platform: "ios" | "android";
|
|
110
115
|
};
|
|
111
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Request with its corresponding response (for UI display)
|
|
119
|
+
*/
|
|
112
120
|
declare enum EventType {
|
|
113
121
|
NETWORK = "NETWORK",
|
|
114
122
|
CONSOLE = "CONSOLE"
|
|
@@ -118,29 +126,6 @@ declare enum EventType {
|
|
|
118
126
|
*/
|
|
119
127
|
type NetworkEvent = ConnectEvent | NetworkRequest | NetworkResponse | NetworkErrorEvent | GraphQLRequest | GraphQLResponse;
|
|
120
128
|
type LimelightEvent = NetworkEvent | ConsoleEvent;
|
|
121
|
-
interface Session {
|
|
122
|
-
id: string;
|
|
123
|
-
appName: string;
|
|
124
|
-
platform: "ios" | "android";
|
|
125
|
-
connectedAt: number;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Request with its corresponding response (for UI display)
|
|
129
|
-
*/
|
|
130
|
-
interface NetworkRequestWithResponse extends NetworkRequest {
|
|
131
|
-
response?: NetworkResponse;
|
|
132
|
-
status?: number;
|
|
133
|
-
duration?: number;
|
|
134
|
-
error?: NetworkErrorEvent;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Request with its corresponding response (for UI display)
|
|
138
|
-
*/
|
|
139
|
-
interface NetworkRequestWithResponse extends NetworkRequest {
|
|
140
|
-
response?: NetworkResponse;
|
|
141
|
-
status?: number;
|
|
142
|
-
duration?: number;
|
|
143
|
-
}
|
|
144
129
|
|
|
145
130
|
/**
|
|
146
131
|
* Console log levels
|
|
@@ -398,9 +383,9 @@ interface LimelightConfig {
|
|
|
398
383
|
*/
|
|
399
384
|
projectKey?: string;
|
|
400
385
|
/**
|
|
401
|
-
* The platform of the application
|
|
386
|
+
* The platform of the application. Auto-detected if not provided.
|
|
402
387
|
*/
|
|
403
|
-
platform?: string;
|
|
388
|
+
platform?: "ios" | "android" | "web" | "react-native" | "node" | (string & {});
|
|
404
389
|
/**
|
|
405
390
|
* The URL of the Limelight server to connect to. If not provided, it falls back to the local wss server url if there is no project key, or the web wss url if there is a project key.
|
|
406
391
|
*/
|
|
@@ -411,26 +396,32 @@ interface LimelightConfig {
|
|
|
411
396
|
appName?: string;
|
|
412
397
|
/**
|
|
413
398
|
* Flag to enable or disable the Limelight SDK.
|
|
399
|
+
* @default true (SDK is enabled by default)
|
|
414
400
|
*/
|
|
415
401
|
enabled?: boolean;
|
|
416
402
|
/**
|
|
417
403
|
* Flag to enable or disable network request inspection.
|
|
404
|
+
* @default true
|
|
418
405
|
*/
|
|
419
406
|
enableNetworkInspector?: boolean;
|
|
420
407
|
/**
|
|
421
408
|
* Flag to enable or disable console event capturing.
|
|
409
|
+
* @default true
|
|
422
410
|
*/
|
|
423
411
|
enableConsole?: boolean;
|
|
424
412
|
/**
|
|
425
413
|
* Flag to enable or disable GraphQL request capturing.
|
|
414
|
+
* @default true
|
|
426
415
|
*/
|
|
427
416
|
enableGraphQL?: boolean;
|
|
428
417
|
/**
|
|
429
418
|
* Flag to disable capturing of request and response bodies.
|
|
419
|
+
* @default false (bodies are captured by default)
|
|
430
420
|
*/
|
|
431
421
|
disableBodyCapture?: boolean;
|
|
432
422
|
/**
|
|
433
423
|
* Flag to enable or disable render inspection.
|
|
424
|
+
* @default true
|
|
434
425
|
*/
|
|
435
426
|
enableRenderInspector?: boolean;
|
|
436
427
|
/**
|
|
@@ -445,12 +436,30 @@ interface LimelightConfig {
|
|
|
445
436
|
enableStateInspector?: boolean;
|
|
446
437
|
/**
|
|
447
438
|
* Flag to enable or disable internal logging for the Limelight SDK
|
|
439
|
+
* @default false
|
|
448
440
|
*/
|
|
449
441
|
enableInternalLogging?: boolean;
|
|
442
|
+
/**
|
|
443
|
+
* Target destination for events. Set to "mcp" to send events to the MCP server at ws://localhost:9229.
|
|
444
|
+
*/
|
|
445
|
+
target?: "mcp";
|
|
446
|
+
/**
|
|
447
|
+
* Custom header name used for trace ID propagation across client and server.
|
|
448
|
+
* @default 'x-limelight-trace-id'
|
|
449
|
+
*/
|
|
450
|
+
traceHeaderName?: string;
|
|
450
451
|
/**
|
|
451
452
|
* A callback function to modify or filter events before they are sent to the server
|
|
452
453
|
*/
|
|
453
454
|
beforeSend?: (event: LimelightMessage) => LimelightMessage | null;
|
|
455
|
+
/**
|
|
456
|
+
* Custom WebSocket implementation for Node.js environments where WebSocket
|
|
457
|
+
* is not globally available (Node < 22). Pass the `ws` package constructor.
|
|
458
|
+
* @example
|
|
459
|
+
* import WebSocket from 'ws';
|
|
460
|
+
* Limelight.connect({ webSocketImpl: WebSocket });
|
|
461
|
+
*/
|
|
462
|
+
webSocketImpl?: new (url: string, protocols?: string | string[]) => WebSocket;
|
|
454
463
|
}
|
|
455
464
|
/**
|
|
456
465
|
* Represents a connection or disconnection event in the Limelight SDK.
|
|
@@ -516,6 +525,41 @@ interface ResponseBridgeConfig {
|
|
|
516
525
|
body?: any;
|
|
517
526
|
}
|
|
518
527
|
|
|
528
|
+
interface MiddlewareOptions {
|
|
529
|
+
/** Maximum body size to capture in bytes. Bodies larger than this are truncated. Default: 64KB */
|
|
530
|
+
maxBodySize?: number;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
type NextApiHandler = (req: IncomingMessage & {
|
|
534
|
+
body?: unknown;
|
|
535
|
+
query?: Record<string, unknown>;
|
|
536
|
+
}, res: ServerResponse) => void | Promise<void>;
|
|
537
|
+
/**
|
|
538
|
+
* Wraps a Next.js Pages API route handler with Limelight request/response capture.
|
|
539
|
+
*
|
|
540
|
+
* NOTE: This works with Next.js Pages Router API routes (`pages/api/`)
|
|
541
|
+
* which use the Node.js `(req, res)` signature. It does NOT work with
|
|
542
|
+
* App Router route handlers (`app/api/`) which use the Web Standard
|
|
543
|
+
* `Request`/`Response` objects. App Router support is planned for a future release.
|
|
544
|
+
*
|
|
545
|
+
* @example
|
|
546
|
+
* ```ts
|
|
547
|
+
* // pages/api/users.ts
|
|
548
|
+
* import { Limelight } from '@getlimelight/sdk';
|
|
549
|
+
*
|
|
550
|
+
* export default Limelight.withLimelight((req, res) => {
|
|
551
|
+
* res.json({ ok: true });
|
|
552
|
+
* });
|
|
553
|
+
* ```
|
|
554
|
+
*
|
|
555
|
+
* @param sendMessage Function to send Limelight messages to the server
|
|
556
|
+
* @param getSessionId Function to retrieve the current Limelight session ID
|
|
557
|
+
* @param getConfig Function to retrieve the current Limelight configuration
|
|
558
|
+
* @param options Optional middleware options (e.g. maxBodySize)
|
|
559
|
+
* @returns A function that wraps a Next.js API route handler with Limelight capture
|
|
560
|
+
*/
|
|
561
|
+
declare const createWithLimelight: (sendMessage: (message: LimelightMessage) => void, getSessionId: () => string, getConfig: () => LimelightConfig | null, options?: MiddlewareOptions) => (handler: NextApiHandler) => NextApiHandler;
|
|
562
|
+
|
|
519
563
|
declare class LimelightClient {
|
|
520
564
|
private ws;
|
|
521
565
|
private config;
|
|
@@ -531,6 +575,7 @@ declare class LimelightClient {
|
|
|
531
575
|
private consoleInterceptor;
|
|
532
576
|
private renderInterceptor;
|
|
533
577
|
private stateInterceptor;
|
|
578
|
+
private errorInterceptor;
|
|
534
579
|
private requestBridge;
|
|
535
580
|
private commandHandler;
|
|
536
581
|
constructor();
|
|
@@ -616,6 +661,37 @@ declare class LimelightClient {
|
|
|
616
661
|
* @param error - The error that occurred
|
|
617
662
|
*/
|
|
618
663
|
failRequest(requestId: string, error: unknown): void;
|
|
664
|
+
/**
|
|
665
|
+
* Returns an Express/Connect-compatible middleware that captures incoming
|
|
666
|
+
* HTTP requests and responses.
|
|
667
|
+
*
|
|
668
|
+
* Place after body-parser middleware (express.json(), etc.) for request body capture.
|
|
669
|
+
*
|
|
670
|
+
* @example
|
|
671
|
+
* ```ts
|
|
672
|
+
* app.use(express.json());
|
|
673
|
+
* app.use(Limelight.middleware());
|
|
674
|
+
* ```
|
|
675
|
+
*/
|
|
676
|
+
middleware(options?: MiddlewareOptions): (req: http.IncomingMessage & {
|
|
677
|
+
body?: unknown;
|
|
678
|
+
}, res: http.ServerResponse, next: () => void) => void;
|
|
679
|
+
/**
|
|
680
|
+
* Wraps a Next.js Pages API route handler with request/response capture.
|
|
681
|
+
* Works with Pages Router (`pages/api/`), not App Router (`app/api/`).
|
|
682
|
+
*
|
|
683
|
+
* @example
|
|
684
|
+
* ```ts
|
|
685
|
+
* // pages/api/users.ts
|
|
686
|
+
* export default Limelight.withLimelight((req, res) => {
|
|
687
|
+
* res.json({ ok: true });
|
|
688
|
+
* });
|
|
689
|
+
* ```
|
|
690
|
+
*/
|
|
691
|
+
withLimelight(handler: Parameters<ReturnType<typeof createWithLimelight>>[0]): (req: http.IncomingMessage & {
|
|
692
|
+
body?: unknown;
|
|
693
|
+
query?: Record<string, unknown>;
|
|
694
|
+
}, res: http.ServerResponse) => void | Promise<void>;
|
|
619
695
|
}
|
|
620
696
|
declare const Limelight: LimelightClient;
|
|
621
697
|
|
|
@@ -623,6 +699,7 @@ declare global {
|
|
|
623
699
|
interface XMLHttpRequest {
|
|
624
700
|
_limelightData?: {
|
|
625
701
|
id: string;
|
|
702
|
+
traceId?: string;
|
|
626
703
|
method: string;
|
|
627
704
|
url: string;
|
|
628
705
|
headers: Record<string, string>;
|
|
@@ -633,4 +710,4 @@ declare global {
|
|
|
633
710
|
}
|
|
634
711
|
}
|
|
635
712
|
|
|
636
|
-
export { type BaseCommand, type BaseNetworkEvent, BodyFormat, type ClearRendersCommand, type Command, type CommandAckEvent, CommandType, type ConnectEvent, type ConnectionEvent, type ConsoleEvent, ConsoleLevel, ConsoleSource, ConsoleType, EventType, type GraphQLRequest, type GraphQLResponse, GraphqlOprtation, HttpMethod, HttpStatusClass, Limelight, type LimelightConfig, type LimelightEvent, type LimelightMessage, type NetworkErrorEvent, type NetworkEvent, NetworkPhase, type NetworkRequest, type
|
|
713
|
+
export { type BaseCommand, type BaseNetworkEvent, BodyFormat, type ClearRendersCommand, type Command, type CommandAckEvent, CommandType, type ConnectEvent, type ConnectionEvent, type ConsoleEvent, ConsoleLevel, ConsoleSource, ConsoleType, EventType, type GraphQLRequest, type GraphQLResponse, GraphqlOprtation, HttpMethod, HttpStatusClass, Limelight, type LimelightConfig, type LimelightEvent, type LimelightMessage, type NetworkErrorEvent, type NetworkEvent, NetworkPhase, type NetworkRequest, type NetworkResponse, NetworkType, type ParsedStackTrace, type RequestBridgeConfig, type ResponseBridgeConfig, type SerializedBody, type StackFrame };
|