@@ -101,6 +101,11 @@ function customLog() {
101101 debugJs . inspectOpts . showHidden === null
102102 ? undefined
103103 : debugJs . inspectOpts . showHidden ,
104+ depth :
105+ debugJs . inspectOpts . depth === null ||
106+ typeof debugJs . inspectOpts . depth === 'boolean'
107+ ? undefined
108+ : debugJs . inspectOpts . depth ,
104109 }
105110 : { }
106111 ReflectApply ( logger . info , logger , [
@@ -113,7 +118,7 @@ function customLog() {
113118 * @private
114119 */
115120/*@__NO_SIDE_EFFECTS__ */
116- function extractOptions ( namespaces : any ) {
121+ function extractOptions ( namespaces : NamespacesOrOptions ) {
117122 return namespaces !== null && typeof namespaces === 'object'
118123 ? { __proto__ : null , ...namespaces }
119124 : { __proto__ : null , namespaces }
@@ -124,7 +129,7 @@ function extractOptions(namespaces: any) {
124129 * @private
125130 */
126131/*@__NO_SIDE_EFFECTS__ */
127- function isEnabled ( namespaces : any ) {
132+ function isEnabled ( namespaces : string | undefined ) {
128133 if ( typeof namespaces !== 'string' || ! namespaces || namespaces === '*' ) {
129134 return true
130135 }
@@ -154,16 +159,29 @@ function isEnabled(namespaces: any) {
154159 * Debug output for object inspection.
155160 */
156161/*@__NO_SIDE_EFFECTS__ */
157- /* c8 ignore start - Debug utilities only used in development. */
158- function debugDirNs ( namespacesOrOpts : any , obj : any , inspectOpts ?: any ) {
162+ function debugDirNs (
163+ namespacesOrOpts : NamespacesOrOptions ,
164+ obj : unknown ,
165+ inspectOpts ?: InspectOptions | undefined ,
166+ ) {
159167 const options = extractOptions ( namespacesOrOpts )
160168 const { namespaces } = options
161169 if ( ! isEnabled ( namespaces ) ) {
162170 return
163171 }
164172 if ( inspectOpts === undefined ) {
165173 const debugJs = getDebugJs ( )
166- inspectOpts = debugJs . inspectOpts
174+ const opts = debugJs . inspectOpts
175+ if ( opts ) {
176+ inspectOpts = {
177+ ...opts ,
178+ showHidden : opts . showHidden === null ? undefined : opts . showHidden ,
179+ depth :
180+ opts . depth === null || typeof opts . depth === 'boolean'
181+ ? null
182+ : opts . depth ,
183+ } as InspectOptions
184+ }
167185 }
168186 const { spinner = /*@__PURE__ */ require ( './constants/spinner.js' ) } = options
169187 const wasSpinning = spinner . isSpinning
@@ -174,15 +192,13 @@ function debugDirNs(namespacesOrOpts: any, obj: any, inspectOpts?: any) {
174192 spinner . start ( )
175193 }
176194}
177- /* c8 ignore stop */
178195
179196let pointingTriangle : string | undefined
180197/**
181198 * Debug output with function name prefix.
182199 */
183200/*@__NO_SIDE_EFFECTS__ */
184- /* c8 ignore start - Debug utilities only used in development. */
185- function debugFnNs ( namespacesOrOpts : NamespacesOrOptions , ...args : any [ ] ) {
201+ function debugFnNs ( namespacesOrOpts : NamespacesOrOptions , ...args : unknown [ ] ) {
186202 const options = extractOptions ( namespacesOrOpts )
187203 const { namespaces } = options
188204 if ( ! isEnabled ( namespaces ) ) {
@@ -248,14 +264,12 @@ function debugFnNs(namespacesOrOpts: NamespacesOrOptions, ...args: any[]) {
248264 spinner . start ( )
249265 }
250266}
251- /* c8 ignore stop */
252267
253268/**
254269 * Debug logging function.
255270 */
256271/*@__NO_SIDE_EFFECTS__ */
257- /* c8 ignore start - Debug utilities only used in development. */
258- function debugLogNs ( namespacesOrOpts : any , ...args : any [ ] ) {
272+ function debugLogNs ( namespacesOrOpts : NamespacesOrOptions , ...args : unknown [ ] ) {
259273 const options = extractOptions ( namespacesOrOpts )
260274 const { namespaces } = options
261275 if ( ! isEnabled ( namespaces ) ) {
@@ -269,62 +283,55 @@ function debugLogNs(namespacesOrOpts: any, ...args: any[]) {
269283 spinner . start ( )
270284 }
271285}
272- /* c8 ignore stop */
273286
274287/**
275288 * Check if debug mode is enabled.
276289 */
277290/*@__NO_SIDE_EFFECTS__ */
278- /* c8 ignore start - Debug utilities only used in development. */
279- function isDebugNs ( namespaces : any ) : boolean {
291+ function isDebugNs ( namespaces : string | undefined ) : boolean {
280292 return ENV . SOCKET_CLI_DEBUG && isEnabled ( namespaces )
281293}
282- /* c8 ignore stop */
283294
284295/**
285296 * Simple debug check based on DEBUG environment variable.
286297 */
287298/*@__NO_SIDE_EFFECTS__ */
288- /* c8 ignore start - Debug utilities only used in development. */
289299export function isDebugSimple ( ) : boolean {
290300 const debug = process . env [ 'DEBUG' ]
291301 if ( ! debug || debug === '' || debug === '0' || debug === 'false' ) {
292302 return false
293303 }
294304 return true
295305}
296- /* c8 ignore stop */
297306
298307/**
299308 * Simple debug log that logs to console when DEBUG is set.
300309 */
301310/*@__NO_SIDE_EFFECTS__ */
302- /* c8 ignore start - Debug utilities only used in development. */
303- export function debugLogSimple ( ...args : any [ ] ) : void {
311+ export function debugLogSimple ( ...args : unknown [ ] ) : void {
304312 if ( isDebugSimple ( ) ) {
305313 console . log ( ...args )
306314 }
307315}
308- /* c8 ignore stop */
309316
310317/**
311318 * Simple debug dir that logs object to console when DEBUG is set.
312319 */
313320/*@__NO_SIDE_EFFECTS__ */
314- /* c8 ignore start - Debug utilities only used in development. */
315- export function debugDirSimple ( obj : any , options ?: any ) : void {
321+ export function debugDirSimple (
322+ obj : unknown ,
323+ options ?: InspectOptions | undefined ,
324+ ) : void {
316325 if ( isDebugSimple ( ) ) {
317326 console . dir ( obj , options || { depth : null , colors : true } )
318327 }
319328}
320- /* c8 ignore stop */
321329
322330/**
323331 * Simple debug function that creates a namespaced debug logger.
324332 */
325333/*@__NO_SIDE_EFFECTS__ */
326- /* c8 ignore start - Debug utilities only used in development. */
327- function matchPattern ( ns : any , pattern : any ) {
334+ function matchPattern ( ns : string , pattern : string ) {
328335 if ( pattern === '*' ) {
329336 return true
330337 }
@@ -342,8 +349,8 @@ function matchPattern(ns: any, pattern: any) {
342349/**
343350 * Create a simple debug function without external dependencies.
344351 */
345- export function debugFnSimple ( namespace : any ) {
346- const log = ( ...args : any [ ] ) => {
352+ export function debugFnSimple ( namespace : string ) {
353+ const log = ( ...args : unknown [ ] ) => {
347354 const debug = process . env [ 'DEBUG' ] || ''
348355
349356 // Parse debug patterns.
@@ -379,45 +386,41 @@ export function debugFnSimple(namespace: any) {
379386
380387 return log
381388}
382- /* c8 ignore stop */
383389
384390/**
385391 * Create a debug logger similar to util.debuglog.
386392 */
387393/*@__NO_SIDE_EFFECTS__ */
388- /* c8 ignore start - Debug utilities only used in development. */
389- export function debuglog ( section : any ) {
390- const log = ( ...args : any [ ] ) => {
394+ export function debuglog ( section : string ) {
395+ const log = ( ...args : unknown [ ] ) => {
391396 if ( isDebugSimple ( ) ) {
392397 console . log ( `[${ section } ]` , ...args )
393398 }
394399 }
395400 return log
396401}
397- /* c8 ignore stop */
398402
399403/**
400404 * Create a debug timer.
401405 */
402406/*@__NO_SIDE_EFFECTS__ */
403- /* c8 ignore start - Debug utilities only used in development. */
404- export function debugtime ( section : any ) {
407+ export function debugtime ( section : string ) {
405408 const timers = new Map ( )
406409
407- const timer = ( label : any ) => {
410+ const timer = ( label : string ) => {
408411 if ( isDebugSimple ( ) ) {
409412 console . log ( `[${ section } ] ${ label } ` )
410413 }
411414 }
412415
413- timer . start = ( label : any ) => {
416+ timer . start = ( label : string ) => {
414417 if ( isDebugSimple ( ) ) {
415418 timers . set ( label , Date . now ( ) )
416419 console . log ( `[${ section } ] ${ label } : start` )
417420 }
418421 }
419422
420- timer . end = ( label : any ) => {
423+ timer . end = ( label : string ) => {
421424 if ( isDebugSimple ( ) ) {
422425 const start = timers . get ( label )
423426 if ( start ) {
@@ -430,7 +433,6 @@ export function debugtime(section: any) {
430433
431434 return timer
432435}
433- /* c8 ignore stop */
434436
435437// Export aliases for compatibility.
436438export { debugDirSimple as debugDir }
0 commit comments