@@ -111,26 +111,108 @@ export interface RegisterOptions {
111111 autoOpenDevtool ?: boolean
112112
113113 /**
114- * @description The option to intercept a certain packet.
115- * If set false, the packet will not be intercepted.
114+ * @description Options for intercepting different types of requests.
115+ * If a property is set to `false`, that specific type of request will not be intercepted.
116+ * By default, all are intercepted if not explicitly set.
116117 */
117118 intercept ?: {
118119 /**
120+ * @description Whether to intercept `fetch` requests.
119121 * @default true
120122 */
121123 fetch ?: boolean
122124 /**
125+ * @description Whether to intercept `http/https` requests.
123126 * @default true
124127 */
125128 normal ?: boolean
126129 /**
130+ * @description Options for intercepting `undici` requests.
131+ * Set to `false` to disable all undici interception.
132+ * Otherwise, configure specific undici interception options.
127133 * @default false
128134 */
129135 undici ?:
130136 | false
131137 | {
138+ /**
139+ * @description Whether to intercept `undici`'s `fetch` requests.
140+ * @default false
141+ */
132142 fetch ?: false | { }
143+ /**
144+ * @description Whether to intercept `undici`'s normal requests.
145+ * @default false
146+ */
133147 normal ?: false | { }
134148 }
135149 }
136150}
151+ export const NETWORK_CONTEXT_KEY = 'x-network-context'
152+ export const WS_PROTOCOL = 'ws'
153+
154+ export const CONTEXT_KEY_PORT = 'x-network-context-port'
155+ export const CONTEXT_KEY_SERVER_PORT = 'x-network-context-server-port'
156+ export const CONTEXT_KEY_AUTO_OPEN_DEVTOOL = 'x-network-context-auto-open-devtools'
157+ export const CONTEXT_KEY_INTERCEPT_NORMAL = 'x-network-context-intercept-normal'
158+ export const CONTEXT_KEY_INTERCEPT_FETCH = 'x-network-context-intercept-fetch'
159+ export const CONTEXT_KEY_INTERCEPT_UNDICI_FETCH = 'x-network-context-intercept-undici-fetch'
160+ export const CONTEXT_KEY_HASH = 'x-network-context-hash'
161+
162+ export interface ConnectOptions {
163+ /**
164+ * @description Main Process Port
165+ * @default 5270
166+ */
167+ port ?: number
168+ }
169+
170+ export interface UnregisterOptions {
171+ /**
172+ * @description Main Process Port
173+ * @default 5270
174+ */
175+ port ?: number
176+ }
177+
178+ export interface SendMessageOptions {
179+ /**
180+ * @description Main Process Port
181+ * @default 5270
182+ */
183+ port ?: number
184+ }
185+ export type RequestPipe = ( req : RequestDetail ) => RequestDetail | null
186+
187+ export interface SetRequestInterceptorOptions {
188+ /**
189+ * @description Main Process Port
190+ * @default 5270
191+ */
192+ port ?: number
193+ request ?: RequestPipe
194+ }
195+ export interface SetResponseInterceptorOptions {
196+ /**
197+ * @description Main Process Port
198+ * @default 5270
199+ */
200+ port ?: number
201+ response ?: RequestPipe
202+ }
203+
204+ export interface RemoveRequestInterceptorOptions {
205+ /**
206+ * @description Main Process Port
207+ * @default 5270
208+ */
209+ port ?: number
210+ }
211+
212+ export interface RemoveResponseInterceptorOptions {
213+ /**
214+ * @description Main Process Port
215+ * @default 5270
216+ */
217+ port ?: number
218+ }
0 commit comments