File tree Expand file tree Collapse file tree 6 files changed +34
-27
lines changed
packages/network-debugger/src/core Expand file tree Collapse file tree 6 files changed +34
-27
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * @deprecated information is not complete
3+ */
14import { ClientRequest , IncomingMessage } from 'http'
25import { MainProcess } from './fork'
36import * as dc from 'node:diagnostics_channel'
Original file line number Diff line number Diff line change @@ -118,41 +118,21 @@ export class MainProcess {
118118 }
119119
120120 public sendRequest ( type : RequestType , request : RequestDetail ) {
121- this . send ( {
122- type,
123- data : request
124- } )
125- return this
126- }
127-
128- public initRequest ( request : RequestDetail ) {
129- this . sendRequest ( 'initRequest' , request )
130- return this
131- }
132-
133- public registerRequest ( request : RequestDetail ) {
134121 const currentCell = getCurrentCell ( )
135122 let req = request
136123 if ( currentCell ) {
137124 currentCell . request = req
138- const pipes = currentCell . pipes . filter ( ( p ) => p . type === 'regsiter' ) . map ( ( p ) => p . pipe )
125+ const pipes = currentCell . pipes . filter ( ( p ) => p . type === type ) . map ( ( p ) => p . pipe )
139126 pipes . forEach ( ( pipe ) => {
140127 req = pipe ( req )
141128 } )
142129 currentCell . request = req
143130 }
144131
145- this . sendRequest ( 'registerRequest' , req )
146- return this
147- }
148-
149- public updateRequest ( request : RequestDetail ) {
150- this . sendRequest ( 'updateRequest' , request )
151- return this
152- }
153-
154- public endRequest ( request : RequestDetail ) {
155- this . sendRequest ( 'endRequest' , request )
132+ this . send ( {
133+ type,
134+ data : request
135+ } )
156136 return this
157137 }
158138
Original file line number Diff line number Diff line change 11import { type RequestDetail } from '../../common'
2+ import { RequestType } from '../fork'
23
34export interface Pipe < T = RequestDetail > {
45 ( req : T ) : T
@@ -8,7 +9,7 @@ export interface Cell {
89 request : RequestDetail
910 pipes : Array < {
1011 pipe : Pipe < RequestDetail >
11- type : 'regsiter'
12+ type : RequestType
1213 } >
1314 /**
1415 * @default false
Original file line number Diff line number Diff line change 11export * from './useRegisterRequest'
2+ export * from './useRequestPipe'
23export * from './useAbortRequest'
34export * from './cell'
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ export const useRegisterRequest: RegisterRequestHook = (pipe) => {
1414
1515 cell . pipes . push ( {
1616 pipe,
17- type : 'regsiter '
17+ type : 'registerRequest '
1818 } )
1919
2020 return
Original file line number Diff line number Diff line change 1+ import { RequestDetail } from '../../common'
2+ import { RequestType } from '../fork'
3+ import { getCurrentCell } from './cell'
4+
5+ export interface RequestPipeHook {
6+ ( type : RequestType , pipe : ( req : RequestDetail ) => RequestDetail ) : void
7+ }
8+
9+ export const useRequestPipe : RequestPipeHook = ( type , pipe ) => {
10+ const cell = getCurrentCell ( )
11+
12+ if ( ! cell ) {
13+ throw new Error ( 'useRequestPipe must be used in request handler' )
14+ }
15+
16+ cell . pipes . push ( {
17+ pipe,
18+ type
19+ } )
20+
21+ return
22+ }
You can’t perform that action at this time.
0 commit comments