@socketsecurity/lib 2.10.3 → 3.0.0
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/CHANGELOG.md +38 -0
- package/README.md +231 -40
- package/dist/constants/platform.js +1 -1
- package/dist/constants/platform.js.map +3 -3
- package/dist/cover/code.js +1 -1
- package/dist/cover/code.js.map +3 -3
- package/dist/debug.js +2 -2
- package/dist/debug.js.map +3 -3
- package/dist/dlx-binary.d.ts +29 -6
- package/dist/dlx-binary.js +7 -7
- package/dist/dlx-binary.js.map +3 -3
- package/dist/dlx-package.d.ts +16 -1
- package/dist/dlx-package.js +7 -7
- package/dist/dlx-package.js.map +3 -3
- package/dist/dlx.js +4 -4
- package/dist/dlx.js.map +3 -3
- package/dist/env/rewire.js +1 -1
- package/dist/env/rewire.js.map +3 -3
- package/dist/env/socket-cli.d.ts +7 -0
- package/dist/env/socket-cli.js +1 -1
- package/dist/env/socket-cli.js.map +2 -2
- package/dist/external/yoctocolors-cjs.d.ts +14 -0
- package/dist/fs.d.ts +82 -27
- package/dist/fs.js +7 -7
- package/dist/fs.js.map +3 -3
- package/dist/git.js +1 -1
- package/dist/git.js.map +3 -3
- package/dist/http-request.js +1 -1
- package/dist/http-request.js.map +3 -3
- package/dist/ipc.js +1 -1
- package/dist/ipc.js.map +3 -3
- package/dist/links/index.d.ts +65 -0
- package/dist/links/index.js +3 -0
- package/dist/links/index.js.map +7 -0
- package/dist/logger.d.ts +21 -18
- package/dist/logger.js +1 -1
- package/dist/logger.js.map +3 -3
- package/dist/packages/isolation.js +1 -1
- package/dist/packages/isolation.js.map +3 -3
- package/dist/paths.js +1 -1
- package/dist/paths.js.map +2 -2
- package/dist/process-lock.js +2 -2
- package/dist/process-lock.js.map +3 -3
- package/dist/promises.d.ts +6 -21
- package/dist/promises.js +1 -1
- package/dist/promises.js.map +2 -2
- package/dist/prompts/index.d.ts +115 -0
- package/dist/prompts/index.js +3 -0
- package/dist/prompts/index.js.map +7 -0
- package/dist/spinner.d.ts +33 -23
- package/dist/spinner.js +1 -1
- package/dist/spinner.js.map +3 -3
- package/dist/stdio/mask.d.ts +2 -2
- package/dist/stdio/mask.js +4 -4
- package/dist/stdio/mask.js.map +3 -3
- package/dist/stdio/stdout.js +1 -1
- package/dist/stdio/stdout.js.map +3 -3
- package/dist/themes/context.d.ts +80 -0
- package/dist/themes/context.js +3 -0
- package/dist/themes/context.js.map +7 -0
- package/dist/themes/index.d.ts +53 -0
- package/dist/themes/index.js +3 -0
- package/dist/themes/index.js.map +7 -0
- package/dist/themes/themes.d.ts +49 -0
- package/dist/themes/themes.js +3 -0
- package/dist/themes/themes.js.map +7 -0
- package/dist/themes/types.d.ts +92 -0
- package/dist/themes/types.js +3 -0
- package/dist/themes/types.js.map +7 -0
- package/dist/themes/utils.d.ts +78 -0
- package/dist/themes/utils.js +3 -0
- package/dist/themes/utils.js.map +7 -0
- package/package.json +40 -8
- package/dist/download-lock.d.ts +0 -49
- package/dist/download-lock.js +0 -10
- package/dist/download-lock.js.map +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,44 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [3.0.0](https://github.com/SocketDev/socket-lib/releases/tag/v3.0.0) - 2025-11-01
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Theme system with 5 built-in themes: `socket`, `sunset`, `brick`, `lush`, `ultra`
|
|
13
|
+
- `setTheme()`, `getTheme()`, `withTheme()`, `withThemeSync()` for theme management
|
|
14
|
+
- `createTheme()`, `extendTheme()`, `resolveColor()` helper functions
|
|
15
|
+
- `onThemeChange()` event listener for theme reactivity
|
|
16
|
+
- `link()` function for themed terminal hyperlinks in `@socketsecurity/lib/links`
|
|
17
|
+
- Logger and spinner now inherit theme colors automatically
|
|
18
|
+
- Spinner methods: `enableShimmer()`, `disableShimmer()`, `setShimmer()`, `updateShimmer()`
|
|
19
|
+
- DLX cross-platform binary resolution (`.cmd`, `.bat`, `.ps1` on Windows)
|
|
20
|
+
- DLX programmatic options aligned with CLI conventions (`force`, `quiet`, `package`)
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- Theme context uses AsyncLocalStorage instead of manual stack management
|
|
25
|
+
- Promise retry options renamed: `factor` → `backoffFactor`, `minTimeout` → `baseDelayMs`, `maxTimeout` → `maxDelayMs`
|
|
26
|
+
|
|
27
|
+
### Removed
|
|
28
|
+
|
|
29
|
+
**BREAKING CHANGES:**
|
|
30
|
+
|
|
31
|
+
- `pushTheme()` and `popTheme()` - use `withTheme()` or `withThemeSync()` instead
|
|
32
|
+
- `logger` export - use `getDefaultLogger()` instead
|
|
33
|
+
- `spinner` export - use `getDefaultSpinner()` instead
|
|
34
|
+
- `download-lock.ts` - use `process-lock.ts` instead
|
|
35
|
+
- Promise option aliases: `factor`, `minTimeout`, `maxTimeout`
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
# Changelog
|
|
40
|
+
|
|
41
|
+
All notable changes to this project will be documented in this file.
|
|
42
|
+
|
|
43
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
44
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
45
|
+
|
|
8
46
|
## [2.10.3](https://github.com/SocketDev/socket-lib/releases/tag/v2.10.3) - 2025-10-31
|
|
9
47
|
|
|
10
48
|
### Fixed
|
package/README.md
CHANGED
|
@@ -1,87 +1,278 @@
|
|
|
1
1
|
# @socketsecurity/lib
|
|
2
2
|
|
|
3
3
|
[](https://socket.dev/npm/package/@socketsecurity/lib)
|
|
4
|
-
[](https://github.com/SocketDev/socket-lib/actions/workflows/ci.yml)
|
|
6
5
|
[](https://twitter.com/SocketSecurity)
|
|
7
|
-
[](https://bsky.app/profile/socket.dev)
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
**Core infrastructure library for Socket.dev security tools** — utilities, constants, and helpers with zero dependencies.
|
|
10
8
|
|
|
11
|
-
##
|
|
9
|
+
## Quick Start
|
|
12
10
|
|
|
13
11
|
```bash
|
|
14
|
-
pnpm
|
|
12
|
+
pnpm add @socketsecurity/lib
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
// Import what you need - tree-shakeable exports
|
|
17
|
+
import { Spinner } from '@socketsecurity/lib/spinner'
|
|
18
|
+
import { readJsonFile } from '@socketsecurity/lib/fs'
|
|
19
|
+
import { NODE_MODULES } from '@socketsecurity/lib/constants/packages'
|
|
20
|
+
|
|
21
|
+
const spinner = Spinner({ text: 'Loading...' })
|
|
22
|
+
spinner.start()
|
|
23
|
+
const pkg = await readJsonFile('./package.json')
|
|
24
|
+
spinner.stop()
|
|
15
25
|
```
|
|
16
26
|
|
|
17
|
-
##
|
|
27
|
+
## 📦 What's Inside
|
|
18
28
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
```
|
|
30
|
+
@socketsecurity/lib
|
|
31
|
+
├── Visual Effects → Spinners, shimmer, themes, logger
|
|
32
|
+
├── File System → fs, paths, globs, temp files
|
|
33
|
+
├── Package Management → npm, pnpm, yarn utilities
|
|
34
|
+
├── Process & Spawn → Safe process spawning, IPC
|
|
35
|
+
├── Environment → 68 typed env getters (CI, paths, etc)
|
|
36
|
+
├── Constants → Node.js, npm, platform constants
|
|
37
|
+
├── Utilities → Arrays, objects, strings, promises
|
|
38
|
+
└── Types → Full TypeScript definitions
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## 💡 Key Features
|
|
24
42
|
|
|
25
|
-
|
|
43
|
+
### Visual Effects
|
|
44
|
+
|
|
45
|
+
**Themed spinners and text effects:**
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
import { Spinner, setTheme } from '@socketsecurity/lib'
|
|
49
|
+
|
|
50
|
+
setTheme('ultra') // 🌈 Rainbow mode!
|
|
51
|
+
const spinner = Spinner({ text: 'Processing...' })
|
|
52
|
+
spinner.enableShimmer()
|
|
53
|
+
spinner.start()
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**5 Built-in Themes:** `socket` (purple) · `coana` · `socket-firewall` · `socket-cli-python` · `ultra` (rainbow)
|
|
57
|
+
|
|
58
|
+
👉 [**Theme System Docs**](./docs/themes.md)
|
|
59
|
+
|
|
60
|
+
### File System
|
|
61
|
+
|
|
62
|
+
**Safe, typed file operations:**
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { readJsonFile, writeJsonFile } from '@socketsecurity/lib/fs'
|
|
66
|
+
|
|
67
|
+
const pkg = await readJsonFile<PackageJson>('./package.json')
|
|
68
|
+
await writeJsonFile('./output.json', { data: pkg })
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Package Management
|
|
72
|
+
|
|
73
|
+
**Parse and validate package specs:**
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
import { parsePackageSpec } from '@socketsecurity/lib/packages'
|
|
77
|
+
|
|
78
|
+
const spec = parsePackageSpec('lodash@^4.17.0')
|
|
79
|
+
// { name: 'lodash', version: '^4.17.0', type: 'range', ... }
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Environment Variables
|
|
83
|
+
|
|
84
|
+
**68 typed environment getters:**
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
import { getCI } from '@socketsecurity/lib/env/ci'
|
|
88
|
+
import { getHome } from '@socketsecurity/lib/env/home'
|
|
89
|
+
import { getNodeEnv } from '@socketsecurity/lib/env/node-env'
|
|
90
|
+
|
|
91
|
+
if (getCI()) {
|
|
92
|
+
console.log('Running in CI')
|
|
93
|
+
}
|
|
94
|
+
```
|
|
26
95
|
|
|
27
96
|
### Constants
|
|
28
97
|
|
|
29
|
-
|
|
98
|
+
**Access platform and Node.js constants:**
|
|
30
99
|
|
|
31
100
|
```typescript
|
|
32
101
|
import {
|
|
33
102
|
NODE_MODULES,
|
|
34
103
|
PACKAGE_JSON,
|
|
35
|
-
PNPM_LOCK_YAML,
|
|
36
104
|
NPM_REGISTRY_URL,
|
|
37
105
|
} from '@socketsecurity/lib/constants/packages'
|
|
106
|
+
|
|
107
|
+
import { DARWIN, WIN32 } from '@socketsecurity/lib/constants/platform'
|
|
38
108
|
```
|
|
39
109
|
|
|
40
|
-
|
|
110
|
+
## Common Patterns
|
|
41
111
|
|
|
42
|
-
|
|
112
|
+
### Spinner with Progress
|
|
43
113
|
|
|
44
114
|
```typescript
|
|
45
|
-
import {
|
|
46
|
-
import { NODE_ENV } from '@socketsecurity/lib/env/node-env'
|
|
115
|
+
import { withSpinner, Spinner } from '@socketsecurity/lib/spinner'
|
|
47
116
|
|
|
48
|
-
|
|
49
|
-
|
|
117
|
+
await withSpinner({
|
|
118
|
+
message: 'Installing packages...',
|
|
119
|
+
spinner: Spinner({ color: [140, 82, 255] }),
|
|
120
|
+
operation: async () => {
|
|
121
|
+
await installPackages()
|
|
122
|
+
}
|
|
123
|
+
})
|
|
50
124
|
```
|
|
51
125
|
|
|
52
|
-
|
|
126
|
+
### Safe Process Spawning
|
|
53
127
|
|
|
54
|
-
|
|
128
|
+
```typescript
|
|
129
|
+
import { spawn } from '@socketsecurity/lib/spawn'
|
|
55
130
|
|
|
56
|
-
|
|
131
|
+
const result = await spawn('npm', ['install'], {
|
|
132
|
+
cwd: '/path/to/project',
|
|
133
|
+
timeout: 30000
|
|
134
|
+
})
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### JSON File Operations
|
|
57
138
|
|
|
58
139
|
```typescript
|
|
59
|
-
import
|
|
60
|
-
PackageJson,
|
|
61
|
-
TsConfig,
|
|
62
|
-
LockFile,
|
|
63
|
-
} from '@socketsecurity/lib/types'
|
|
64
|
-
```
|
|
140
|
+
import { readJsonFile, writeJsonFile } from '@socketsecurity/lib/fs'
|
|
65
141
|
|
|
66
|
-
|
|
142
|
+
const data = await readJsonFile('./config.json')
|
|
143
|
+
data.version = '2.0.0'
|
|
144
|
+
await writeJsonFile('./config.json', data)
|
|
145
|
+
```
|
|
67
146
|
|
|
68
|
-
|
|
147
|
+
### Promise Utilities
|
|
69
148
|
|
|
70
149
|
```typescript
|
|
71
|
-
|
|
72
|
-
import { readJsonFile, writeJsonFile } from '@socketsecurity/lib/fs'
|
|
150
|
+
import { timeout, retry } from '@socketsecurity/lib/promises'
|
|
73
151
|
|
|
74
|
-
//
|
|
75
|
-
|
|
152
|
+
// Timeout after 5 seconds
|
|
153
|
+
const result = await timeout(fetchData(), 5000)
|
|
154
|
+
|
|
155
|
+
// Retry up to 3 times
|
|
156
|
+
const data = await retry(() => fetchData(), { maxAttempts: 3 })
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Module Organization
|
|
160
|
+
|
|
161
|
+
**120+ granular exports** organized by category:
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
/constants/ → Node.js, npm, platform constants
|
|
165
|
+
├─ packages → PACKAGE_JSON, NODE_MODULES, etc.
|
|
166
|
+
├─ platform → DARWIN, WIN32, S_IXUSR, etc.
|
|
167
|
+
├─ node → NODE_VERSION, NODE_PATH, etc.
|
|
168
|
+
├─ time → MILLISECONDS_PER_*, DLX_BINARY_CACHE_TTL
|
|
169
|
+
└─ encoding → UTF8, CHAR_* codes
|
|
170
|
+
|
|
171
|
+
/env/ → 68 typed environment getters
|
|
172
|
+
├─ ci → getCI() - Detect CI environment
|
|
173
|
+
├─ home → getHome() - User home directory
|
|
174
|
+
├─ node-env → getNodeEnv() - NODE_ENV value
|
|
175
|
+
└─ ... → And 65 more!
|
|
176
|
+
|
|
177
|
+
/packages/ → Package management utilities
|
|
178
|
+
├─ validation → Package name/version validation
|
|
179
|
+
├─ operations → Install, extract, manifest
|
|
180
|
+
├─ registry → npm registry utilities
|
|
181
|
+
└─ editable → Editable installs detection
|
|
182
|
+
|
|
183
|
+
/effects/ → Visual effects for CLI
|
|
184
|
+
├─ text-shimmer → Animated gradient text
|
|
185
|
+
├─ pulse-frames → Pulsing text effect
|
|
186
|
+
└─ ultra → Rainbow gradients
|
|
76
187
|
|
|
77
|
-
|
|
78
|
-
|
|
188
|
+
/stdio/ → Terminal I/O utilities
|
|
189
|
+
├─ stdout → Safe stdout operations
|
|
190
|
+
├─ stderr → Safe stderr operations
|
|
191
|
+
├─ clear → Clear terminal
|
|
192
|
+
└─ footer → Terminal footers
|
|
79
193
|
|
|
80
|
-
|
|
194
|
+
/themes/ → Theme system for consistent branding
|
|
195
|
+
├─ types → Theme type definitions
|
|
196
|
+
├─ themes → 5 built-in themes
|
|
197
|
+
├─ context → Global theme management
|
|
198
|
+
└─ utils → Color resolution, theme creation
|
|
81
199
|
```
|
|
82
200
|
|
|
83
|
-
|
|
201
|
+
## Documentation
|
|
202
|
+
|
|
203
|
+
| Doc | Description |
|
|
204
|
+
|-----|-------------|
|
|
205
|
+
| [**Getting Started**](./docs/getting-started.md) | Development workflow, commands, architecture |
|
|
206
|
+
| [**Theme System**](./docs/themes.md) | Themed spinners, colors, and effects |
|
|
207
|
+
| [**Build Architecture**](./docs/build.md) | Vendored dependencies, build system |
|
|
208
|
+
| [**CLAUDE.md**](./CLAUDE.md) | Coding standards and patterns |
|
|
209
|
+
|
|
210
|
+
## Architecture
|
|
211
|
+
|
|
212
|
+
```
|
|
213
|
+
┌─────────────────────────────────────────────────────┐
|
|
214
|
+
│ @socketsecurity/lib │
|
|
215
|
+
│ Zero runtime dependencies │
|
|
216
|
+
├─────────────────────────────────────────────────────┤
|
|
217
|
+
│ src/ │
|
|
218
|
+
│ ├── constants/ 14 modules │
|
|
219
|
+
│ ├── env/ 68 getters │
|
|
220
|
+
│ ├── packages/ 12 utilities │
|
|
221
|
+
│ ├── effects/ 4 visual effects │
|
|
222
|
+
│ ├── stdio/ 9 I/O utilities │
|
|
223
|
+
│ ├── themes/ Theme system │
|
|
224
|
+
│ ├── external/ 40+ vendored deps │
|
|
225
|
+
│ └── ... 60+ more modules │
|
|
226
|
+
├─────────────────────────────────────────────────────┤
|
|
227
|
+
│ Build: esbuild → CommonJS (ES2022) │
|
|
228
|
+
│ Types: tsgo (TypeScript Native Preview) │
|
|
229
|
+
│ Tests: Vitest (4600+ tests, 100% coverage) │
|
|
230
|
+
└─────────────────────────────────────────────────────┘
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## Development
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
# Setup
|
|
237
|
+
git clone https://github.com/SocketDev/socket-lib.git
|
|
238
|
+
cd socket-lib
|
|
239
|
+
pnpm install
|
|
240
|
+
|
|
241
|
+
# Build
|
|
242
|
+
pnpm run build # Production build
|
|
243
|
+
pnpm run dev # Watch mode
|
|
244
|
+
|
|
245
|
+
# Test
|
|
246
|
+
pnpm test # Run all tests
|
|
247
|
+
pnpm run cover # With coverage
|
|
248
|
+
|
|
249
|
+
# Quality
|
|
250
|
+
pnpm run check # Type check
|
|
251
|
+
pnpm run lint # Lint code
|
|
252
|
+
pnpm run fix # Auto-fix issues
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Stats
|
|
256
|
+
|
|
257
|
+
- **183** TypeScript modules
|
|
258
|
+
- **120+** granular exports
|
|
259
|
+
- **68** typed environment getters
|
|
260
|
+
- **14** constant modules
|
|
261
|
+
- **4600+** tests passing
|
|
262
|
+
- **Zero** runtime dependencies
|
|
263
|
+
|
|
264
|
+
## Contributing
|
|
265
|
+
|
|
266
|
+
See [CLAUDE.md](./CLAUDE.md) for:
|
|
267
|
+
- Code style and patterns
|
|
268
|
+
- Path alias usage
|
|
269
|
+
- Testing guidelines
|
|
270
|
+
- Build system details
|
|
84
271
|
|
|
85
272
|
## License
|
|
86
273
|
|
|
87
274
|
MIT
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
**Built by Socket.dev** — [socket.dev](https://socket.dev) | [@SocketSecurity](https://twitter.com/SocketSecurity)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* Socket Lib - Built with esbuild */
|
|
2
|
-
var p=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var S=(t,o)=>{for(var n in o)p(t,n,{get:o[n],enumerable:!0})},_=(t,o,n,c)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of I(o))!m.call(t,r)&&r!==n&&p(t,r,{get:()=>o[r],enumerable:!(c=x(o,r))||c.enumerable});return t};var a=t=>_(p({},"__esModule",{value:!0}),t);var w={};S(w,{DARWIN:()=>f,S_IXGRP:()=>X,S_IXOTH:()=>l,S_IXUSR:()=>R,WIN32:()=>i});module.exports=a(w);var s=require("
|
|
2
|
+
var p=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var S=(t,o)=>{for(var n in o)p(t,n,{get:o[n],enumerable:!0})},_=(t,o,n,c)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of I(o))!m.call(t,r)&&r!==n&&p(t,r,{get:()=>o[r],enumerable:!(c=x(o,r))||c.enumerable});return t};var a=t=>_(p({},"__esModule",{value:!0}),t);var w={};S(w,{DARWIN:()=>f,S_IXGRP:()=>X,S_IXOTH:()=>l,S_IXUSR:()=>R,WIN32:()=>i});module.exports=a(w);var s=require("os");const e=(0,s.platform)(),f=e==="darwin",i=e==="win32",R=64,X=8,l=1;0&&(module.exports={DARWIN,S_IXGRP,S_IXOTH,S_IXUSR,WIN32});
|
|
3
3
|
//# sourceMappingURL=platform.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/constants/platform.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Platform detection and OS-specific constants.\n */\n\nimport { platform } from '
|
|
5
|
-
"mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,YAAAE,EAAA,YAAAC,EAAA,YAAAC,EAAA,YAAAC,EAAA,UAAAC,IAAA,eAAAC,EAAAP,GAIA,IAAAQ,EAAyB,
|
|
6
|
-
"names": ["platform_exports", "__export", "DARWIN", "S_IXGRP", "S_IXOTH", "S_IXUSR", "WIN32", "__toCommonJS", "
|
|
4
|
+
"sourcesContent": ["/**\n * Platform detection and OS-specific constants.\n */\n\nimport { platform } from 'os'\n\n// Platform detection.\nconst _platform = platform()\nexport const DARWIN = _platform === 'darwin'\nexport const WIN32 = _platform === 'win32'\n\n// File permission modes.\nexport const S_IXUSR = 0o100\nexport const S_IXGRP = 0o010\nexport const S_IXOTH = 0o001\n"],
|
|
5
|
+
"mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,YAAAE,EAAA,YAAAC,EAAA,YAAAC,EAAA,YAAAC,EAAA,UAAAC,IAAA,eAAAC,EAAAP,GAIA,IAAAQ,EAAyB,cAGzB,MAAMC,KAAY,YAAS,EACdP,EAASO,IAAc,SACvBH,EAAQG,IAAc,QAGtBJ,EAAU,GACVF,EAAU,EACVC,EAAU",
|
|
6
|
+
"names": ["platform_exports", "__export", "DARWIN", "S_IXGRP", "S_IXOTH", "S_IXUSR", "WIN32", "__toCommonJS", "import_os", "_platform"]
|
|
7
7
|
}
|
package/dist/cover/code.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* Socket Lib - Built with esbuild */
|
|
2
|
-
var u=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var O=(e,o)=>{for(var c in o)u(e,c,{get:o[c],enumerable:!0})},j=(e,o,c,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of w(o))!y.call(e,a)&&a!==c&&u(e,a,{get:()=>o[a],enumerable:!(n=b(o,a))||n.enumerable});return e};var E=e=>j(u({},"__esModule",{value:!0}),e);var D={};O(D,{getCodeCoverage:()=>x});module.exports=E(D);var m=require("
|
|
2
|
+
var u=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var O=(e,o)=>{for(var c in o)u(e,c,{get:o[c],enumerable:!0})},j=(e,o,c,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of w(o))!y.call(e,a)&&a!==c&&u(e,a,{get:()=>o[a],enumerable:!(n=b(o,a))||n.enumerable});return e};var E=e=>j(u({},"__esModule",{value:!0}),e);var D={};O(D,{getCodeCoverage:()=>x});module.exports=E(D);var m=require("fs"),_=require("../fs"),i=require("../objects"),C=require("../spawn");let v;function M(){return v===void 0&&(v=require("node:path")),v}async function x(e){const c={__proto__:null,coveragePath:M().join(process.cwd(),"coverage/coverage-final.json"),generateIfMissing:!1,...e},{coveragePath:n,generateIfMissing:a}=c;if(!n)throw new Error("Coverage path is required");if(!await m.promises.access(n).then(()=>!0).catch(()=>!1))if(a)await(0,C.spawn)("vitest",["run","--coverage"],{cwd:process.cwd(),stdio:"inherit"});else throw new Error(`Coverage file not found at "${n}". Run tests with coverage first.`);const p=await(0,_.readJson)(n);if(!(0,i.isObjectObject)(p))throw new Error(`Invalid coverage data format in "${n}"`);const t={__proto__:null,branches:{__proto__:null,covered:0,total:0},functions:{__proto__:null,covered:0,total:0},lines:{__proto__:null,covered:0,total:0},statements:{__proto__:null,covered:0,total:0}},h=p;for(const d of Object.values(h)){if(!(0,i.isObjectObject)(d))continue;const r=d;if(r.s&&(0,i.isObjectObject)(r.s)){const f=Object.values(r.s);for(const s of f)typeof s=="number"&&(t.statements.total+=1,s>0&&(t.statements.covered+=1))}if(r.b&&(0,i.isObjectObject)(r.b)){const f=Object.values(r.b);for(const s of f)if(Array.isArray(s))for(const g of s)typeof g=="number"&&(t.branches.total+=1,g>0&&(t.branches.covered+=1))}if(r.f&&(0,i.isObjectObject)(r.f)){const f=Object.values(r.f);for(const s of f)typeof s=="number"&&(t.functions.total+=1,s>0&&(t.functions.covered+=1))}t.lines.covered=t.statements.covered,t.lines.total=t.statements.total}return{branches:l(t.branches),functions:l(t.functions),lines:l(t.lines),statements:l(t.statements)}}function l(e){const o=e.total===0?"0.00":(e.covered/e.total*100).toFixed(2);return{covered:e.covered,percent:o,total:e.total}}0&&(module.exports={getCodeCoverage});
|
|
3
3
|
//# sourceMappingURL=code.js.map
|
package/dist/cover/code.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/cover/code.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * @fileoverview Code coverage utilities for parsing v8 coverage data.\n */\n\nimport { promises as fs } from '
|
|
5
|
-
"mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,IAAA,eAAAC,EAAAH,GAIA,IAAAI,EAA+B,
|
|
6
|
-
"names": ["code_exports", "__export", "getCodeCoverage", "__toCommonJS", "
|
|
4
|
+
"sourcesContent": ["/**\n * @fileoverview Code coverage utilities for parsing v8 coverage data.\n */\n\nimport { promises as fs } from 'fs'\n\nimport { readJson } from '../fs'\nimport { isObjectObject } from '../objects'\nimport { spawn } from '../spawn'\n\nimport type {\n CodeCoverageResult,\n CoverageMetric,\n GetCodeCoverageOptions,\n V8CoverageData,\n V8FileCoverage,\n} from './types'\n\nlet _path: typeof import('path') | undefined\n/**\n * Lazily load the path module to avoid Webpack errors.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getPath() {\n if (_path === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _path = /*@__PURE__*/ require('node:path')\n }\n return _path as typeof import('path')\n}\n\n/**\n * Get code coverage metrics from v8 coverage-final.json.\n *\n * @throws {Error} When coverage file doesn't exist and generateIfMissing is false.\n * @throws {Error} When coverage data format is invalid.\n */\nexport async function getCodeCoverage(\n options?: GetCodeCoverageOptions | undefined,\n): Promise<CodeCoverageResult> {\n const path = getPath()\n const opts = {\n __proto__: null,\n coveragePath: path.join(process.cwd(), 'coverage/coverage-final.json'),\n generateIfMissing: false,\n ...options,\n } as GetCodeCoverageOptions\n\n const { coveragePath, generateIfMissing } = opts\n\n if (!coveragePath) {\n throw new Error('Coverage path is required')\n }\n\n // Check if coverage file exists.\n const coverageExists = await fs\n .access(coveragePath)\n .then(() => true)\n .catch(() => false)\n\n if (!coverageExists) {\n if (generateIfMissing) {\n // Run vitest to generate coverage.\n await spawn('vitest', ['run', '--coverage'], {\n cwd: process.cwd(),\n stdio: 'inherit',\n })\n } else {\n throw new Error(\n `Coverage file not found at \"${coveragePath}\". Run tests with coverage first.`,\n )\n }\n }\n\n // Read and parse coverage-final.json.\n const coverageData = (await readJson(coveragePath)) as unknown\n\n if (!isObjectObject(coverageData)) {\n throw new Error(`Invalid coverage data format in \"${coveragePath}\"`)\n }\n\n // Aggregate metrics across all files.\n const totals = {\n __proto__: null,\n branches: { __proto__: null, covered: 0, total: 0 },\n functions: { __proto__: null, covered: 0, total: 0 },\n lines: { __proto__: null, covered: 0, total: 0 },\n statements: { __proto__: null, covered: 0, total: 0 },\n }\n\n const v8Data = coverageData as V8CoverageData\n\n for (const fileCoverage of Object.values(v8Data)) {\n if (!isObjectObject(fileCoverage)) {\n continue\n }\n\n const fc = fileCoverage as V8FileCoverage\n\n // Aggregate statements.\n if (fc.s && isObjectObject(fc.s)) {\n const statementCounts = Object.values(fc.s)\n for (const count of statementCounts) {\n if (typeof count === 'number') {\n totals.statements.total += 1\n if (count > 0) {\n totals.statements.covered += 1\n }\n }\n }\n }\n\n // Aggregate branches.\n if (fc.b && isObjectObject(fc.b)) {\n const branchCounts = Object.values(fc.b)\n for (const branches of branchCounts) {\n if (Array.isArray(branches)) {\n for (const count of branches) {\n if (typeof count === 'number') {\n totals.branches.total += 1\n if (count > 0) {\n totals.branches.covered += 1\n }\n }\n }\n }\n }\n }\n\n // Aggregate functions.\n if (fc.f && isObjectObject(fc.f)) {\n const functionCounts = Object.values(fc.f)\n for (const count of functionCounts) {\n if (typeof count === 'number') {\n totals.functions.total += 1\n if (count > 0) {\n totals.functions.covered += 1\n }\n }\n }\n }\n\n // Note: Lines are typically derived from statement map in v8.\n // For simplicity, we use statements as a proxy for lines.\n // In a production implementation, you'd parse statementMap to get actual line coverage.\n totals.lines.covered = totals.statements.covered\n totals.lines.total = totals.statements.total\n }\n\n // Calculate percentages.\n return {\n branches: calculateMetric(totals.branches),\n functions: calculateMetric(totals.functions),\n lines: calculateMetric(totals.lines),\n statements: calculateMetric(totals.statements),\n }\n}\n\n/**\n * Calculate coverage metric with percentage.\n */\nfunction calculateMetric(data: {\n covered: number\n total: number\n}): CoverageMetric {\n const percent =\n data.total === 0 ? '0.00' : ((data.covered / data.total) * 100).toFixed(2)\n\n return {\n covered: data.covered,\n percent,\n total: data.total,\n }\n}\n"],
|
|
5
|
+
"mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,IAAA,eAAAC,EAAAH,GAIA,IAAAI,EAA+B,cAE/BA,EAAyB,iBACzBC,EAA+B,sBAC/BC,EAAsB,oBAUtB,IAAIC,EAMJ,SAASC,GAAU,CACjB,OAAID,IAAU,SAGZA,EAAsB,QAAQ,WAAW,GAEpCA,CACT,CAQA,eAAsBL,EACpBO,EAC6B,CAE7B,MAAMC,EAAO,CACX,UAAW,KACX,aAHWF,EAAQ,EAGA,KAAK,QAAQ,IAAI,EAAG,8BAA8B,EACrE,kBAAmB,GACnB,GAAGC,CACL,EAEM,CAAE,aAAAE,EAAc,kBAAAC,CAAkB,EAAIF,EAE5C,GAAI,CAACC,EACH,MAAM,IAAI,MAAM,2BAA2B,EAS7C,GAAI,CALmB,MAAM,EAAAE,SAC1B,OAAOF,CAAY,EACnB,KAAK,IAAM,EAAI,EACf,MAAM,IAAM,EAAK,EAGlB,GAAIC,EAEF,QAAM,SAAM,SAAU,CAAC,MAAO,YAAY,EAAG,CAC3C,IAAK,QA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AW,GAIpC,CAKAA,EAAO,MAAM,QAAUA,EAAO,WAAW,QACzCA,EAAO,MAAM,MAAQA,EAAO,WAAW,KACzC,CAGA,MAAO,CACL,SAAUS,EAAgBT,EAAO,QAAQ,EACzC,UAAWS,EAAgBT,EAAO,SAAS,EAC3C,MAAOS,EAAgBT,EAAO,KAAK,EACnC,WAAYS,EAAgBT,EAAO,UAAU,CAC/C,CACF,CAKA,SAASS,EAAgBC,EAGN,CACjB,MAAMC,EACJD,EAAK,QAAU,EAAI,QAAWA,EAAK,QAAUA,EAAK,MAAS,KAAK,QAAQ,CAAC,EAE3E,MAAO,CACL,QAASA,EAAK,QACd,QAAAC,EACA,MAAOD,EAAK,KACd,CACF",
|
|
6
|
+
"names": ["code_exports", "__export", "getCodeCoverage", "__toCommonJS", "import_fs", "import_objects", "import_spawn", "_path", "getPath", "options", "opts", "coveragePath", "generateIfMissing", "fs", "coverageData", "totals", "v8Data", "fileCoverage", "fc", "statementCounts", "count", "branchCounts", "branches", "functionCounts", "calculateMetric", "data", "percent"]
|
|
7
7
|
}
|
package/dist/debug.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/* Socket Lib - Built with esbuild */
|
|
2
|
-
var
|
|
3
|
-
`)if(u+=1,u<n)c=s+1;else{const r=o.slice(c,s).trimStart(),w=/(?<=^at\s+).*?(?=\s+\(|$)/.exec(r)?.[0];if(w&&(t=w.replace(/^(?:async|bound|get|new|set)\s+/,""),t.startsWith("Object."))){const
|
|
2
|
+
var j=Object.create;var h=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,W=Object.prototype.hasOwnProperty;var J=(n,t)=>{for(var e in t)h(n,e,{get:t[e],enumerable:!0})},S=(n,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of G(t))!W.call(n,o)&&o!==e&&h(n,o,{get:()=>t[o],enumerable:!(i=L(t,o))||i.enumerable});return n};var I=(n,t,e)=>(e=n!=null?j(T(n)):{},S(t||!n||!n.__esModule?h(e,"default",{value:n,enumerable:!0}):e,n)),R=n=>S(h({},"__esModule",{value:!0}),n);var Z={};J(Z,{debug:()=>F,debugCache:()=>P,debugCacheNs:()=>M,debugDir:()=>K,debugDirNs:()=>A,debugLog:()=>Q,debugLogNs:()=>U,debugNs:()=>B,debuglog:()=>X,debugtime:()=>Y,isDebug:()=>V,isDebugNs:()=>z});module.exports=R(Z);var m=require("#constants/process"),E=require("#env/debug"),a=require("#env/socket"),g=I(require("./external/@socketregistry/is-unicode-supported")),f=I(require("./external/debug")),H=require("./logger"),v=require("./objects"),x=require("./strings");const d=(0,H.getDefaultLogger)(),$=Reflect.apply,_=new Map;function C(n){let t=_.get(n);return t||(!(0,E.getDebug)()&&(0,a.getSocketDebug)()&&(n==="error"||n==="notice")&&f.default.enable(n),t=(0,f.default)(n),t.log=q,_.set(n,t),t)}let k;function N(){return k===void 0&&(k=require("node:util")),k}function b(n=3){let t="";const e=Error.captureStackTrace;if(typeof e=="function"){const i={};e(i,b);const o=i.stack;if(typeof o=="string"){let u=0,c=0;for(let s=0,{length:l}=o;s<l;s+=1)if(o[s]===`
|
|
3
|
+
`)if(u+=1,u<n)c=s+1;else{const r=o.slice(c,s).trimStart(),w=/(?<=^at\s+).*?(?=\s+\(|$)/.exec(r)?.[0];if(w&&(t=w.replace(/^(?:async|bound|get|new|set)\s+/,""),t.startsWith("Object."))){const D=t.slice(7);(0,v.hasOwn)(Object,D)||(t=D)}break}}}return t}function q(...n){const t=N(),e=f.default.inspectOpts?{...f.default.inspectOpts,showHidden:f.default.inspectOpts.showHidden===null?void 0:f.default.inspectOpts.showHidden,depth:f.default.inspectOpts.depth===null||typeof f.default.inspectOpts.depth=="boolean"?void 0:f.default.inspectOpts.depth}:{};$(d.info,d,[t.formatWithOptions(e,...n)])}function y(n){return n!==null&&typeof n=="object"?{__proto__:null,...n}:{__proto__:null,namespaces:n}}function O(n){if(!(0,a.getSocketDebug)())return!1;if(typeof n!="string"||!n||n==="*")return!0;const t=n.trim().replace(/\s+/g,",").split(",").filter(Boolean),e=[],i=[];for(const o of t)o.startsWith("-")?i.push(o.slice(1)):e.push(o);return e.length&&!e.some(o=>C(o).enabled)?!1:i.every(o=>!C(o).enabled)}function A(n,t,e){const i=y(n),{namespaces:o}=i;if(!O(o))return;const u=b(4)||"anonymous";p===void 0&&(p=(0,g.default)()?"\u25B8":">");let c=e;if(c===void 0){const r=f.default.inspectOpts;r&&(c={...r,showHidden:r.showHidden===null?void 0:r.showHidden,depth:r.depth===null||typeof r.depth=="boolean"?null:r.depth})}const s=i.spinner||(0,m.getSpinner)(),l=s?.isSpinning;s?.stop(),d.info(`[DEBUG] ${u} ${p} object inspection:`),d.dir(t,e),l&&s?.start()}let p;function B(n,...t){const e=y(n),{namespaces:i}=e;if(!O(i))return;const o=b(4)||"anonymous";p===void 0&&(p=(0,g.default)()?"\u25B8":">");const u=t.at(0),c=typeof u=="string"?[(0,x.applyLinePrefix)(`${o?`${o} ${p} `:""}${u}`,{prefix:"[DEBUG] "}),...t.slice(1)]:t,s=e.spinner||(0,m.getSpinner)(),l=s?.isSpinning;s?.stop(),$(d.info,d,c),l&&s?.start()}function U(n,...t){const e=y(n),{namespaces:i}=e;if(!O(i))return;const o=b(4)||"anonymous";p===void 0&&(p=(0,g.default)()?"\u25B8":">");const u=t.at(0),c=typeof u=="string"?[(0,x.applyLinePrefix)(`${o?`${o} ${p} `:""}${u}`,{prefix:"[DEBUG] "}),...t.slice(1)]:[`[DEBUG] ${o} ${p}`,...t],s=e.spinner||(0,m.getSpinner)(),l=s?.isSpinning;s?.stop(),$(d.info,d,c),l&&s?.start()}function M(n,t,e,i){const o=y(n),{namespaces:u}=o;if(!O(u))return;const c=b(4)||"cache";p===void 0&&(p=(0,g.default)()?"\u25B8":">");const s=`[CACHE] ${c} ${p} ${t}: ${e}`,l=i!==void 0?[s,i]:[s],r=o.spinner||(0,m.getSpinner)(),w=r?.isSpinning;r?.stop(),$(d.info,d,l),w&&r?.start()}function P(n,t,e){if(!(0,a.getSocketDebug)())return;const i=b(3)||"cache";p===void 0&&(p=(0,g.default)()?"\u25B8":">");const o=`[CACHE] ${i} ${p} ${n}: ${t}`;console.log(...e!==void 0?[o,e]:[o])}function z(n){return!!(0,a.getSocketDebug)()&&O(n)}function F(...n){B("*",...n)}function K(n,t){A("*",n,t)}function Q(...n){U("*",...n)}function V(){return!!(0,a.getSocketDebug)()}function X(n){return N().debuglog(n)}function Y(n){const t=N();let e;const i=()=>{if(e===void 0)e=Date.now();else{const o=Date.now()-e;t.debuglog("time")(`${n}: ${o}ms`),e=void 0}};return i.start=()=>{e=Date.now()},i.end=()=>{if(e!==void 0){const o=Date.now()-e;t.debuglog("time")(`${n}: ${o}ms`),e=void 0}},i}0&&(module.exports={debug,debugCache,debugCacheNs,debugDir,debugDirNs,debugLog,debugLogNs,debugNs,debuglog,debugtime,isDebug,isDebugNs});
|
|
4
4
|
//# sourceMappingURL=debug.js.map
|
package/dist/debug.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/debug.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * @fileoverview Debug logging utilities with lazy loading and environment-based control.\n * Provides Socket CLI specific debug functionality and logging formatters.\n */\n\nimport { getSpinner } from '#constants/process'\nimport { getDebug } from '#env/debug'\nimport { getSocketDebug } from '#env/socket'\nimport isUnicodeSupported from './external/@socketregistry/is-unicode-supported'\nimport debugJs from './external/debug'\n\nimport { logger } from './logger'\nimport { hasOwn } from './objects'\nimport { applyLinePrefix } from './strings'\n\n// IMPORTANT: Do not use destructuring here - use direct assignment instead.\n// tsgo has a bug that incorrectly transpiles destructured exports, resulting in\n// `exports.SomeName = void 0;` which causes runtime errors.\n// See: https://github.com/SocketDev/socket-packageurl-js/issues/3\nconst ReflectApply = Reflect.apply\n\n// Type definitions\ninterface DebugOptions {\n namespaces?: string\n spinner?: { isSpinning: boolean; stop(): void; start(): void }\n [key: string]: unknown\n}\n\ntype NamespacesOrOptions = string | DebugOptions\n\ninterface InspectOptions {\n depth?: number | null\n colors?: boolean\n [key: string]: unknown\n}\n\nexport type { DebugOptions, NamespacesOrOptions, InspectOptions }\n\nconst debugByNamespace = new Map()\n/**\n * Get or create a debug instance for a namespace.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getDebugJsInstance(namespace: string) {\n let inst = debugByNamespace.get(namespace)\n if (inst) {\n return inst\n }\n if (\n !getDebug() &&\n getSocketDebug() &&\n (namespace === 'error' || namespace === 'notice')\n ) {\n debugJs.enable(namespace)\n }\n inst = debugJs(namespace)\n inst.log = customLog\n debugByNamespace.set(namespace, inst)\n return inst\n}\n\nlet _util: typeof import('util') | undefined\n/**\n * Lazily load the util module.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getUtil() {\n if (_util === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _util = /*@__PURE__*/ require('node:util')\n }\n return _util as typeof import('util')\n}\n\n/**\n * Extract caller information from the stack trace.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getCallerInfo(stackOffset: number = 3): string {\n let name = ''\n const captureStackTrace = Error.captureStackTrace\n if (typeof captureStackTrace === 'function') {\n const obj: { stack?: unknown } = {}\n captureStackTrace(obj, getCallerInfo)\n const stack = obj.stack\n if (typeof stack === 'string') {\n let lineCount = 0\n let lineStart = 0\n for (let i = 0, { length } = stack; i < length; i += 1) {\n if (stack[i] === '\\n') {\n lineCount += 1\n if (lineCount < stackOffset) {\n // Store the start index of the next line.\n lineStart = i + 1\n } else {\n // Extract the full line and trim it.\n const line = stack.slice(lineStart, i).trimStart()\n // Match the function name portion (e.g., \"async runFix\").\n const match = /(?<=^at\\s+).*?(?=\\s+\\(|$)/.exec(line)?.[0]\n if (match) {\n name = match\n // Strip known V8 invocation prefixes to get the name.\n .replace(/^(?:async|bound|get|new|set)\\s+/, '')\n if (name.startsWith('Object.')) {\n // Strip leading 'Object.' if not an own property of Object.\n const afterDot = name.slice(7 /*'Object.'.length*/)\n if (!hasOwn(Object, afterDot)) {\n name = afterDot\n }\n }\n }\n break\n }\n }\n }\n }\n }\n return name\n}\n\n/**\n * Custom log function for debug output.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction customLog(...args: unknown[]) {\n const util = getUtil()\n const inspectOpts = debugJs.inspectOpts\n ? {\n ...debugJs.inspectOpts,\n showHidden:\n debugJs.inspectOpts.showHidden === null\n ? undefined\n : debugJs.inspectOpts.showHidden,\n depth:\n debugJs.inspectOpts.depth === null ||\n typeof debugJs.inspectOpts.depth === 'boolean'\n ? undefined\n : debugJs.inspectOpts.depth,\n }\n : {}\n ReflectApply(logger.info, logger, [\n util.formatWithOptions(inspectOpts, ...args),\n ])\n}\n\n/**\n * Extract options from namespaces parameter.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction extractOptions(namespaces: NamespacesOrOptions): DebugOptions {\n return namespaces !== null && typeof namespaces === 'object'\n ? ({ __proto__: null, ...namespaces } as DebugOptions)\n : ({ __proto__: null, namespaces } as DebugOptions)\n}\n\n/**\n * Check if debug is enabled for given namespaces.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction isEnabled(namespaces: string | undefined) {\n // Check if debugging is enabled at all\n if (!getSocketDebug()) {\n return false\n }\n if (typeof namespaces !== 'string' || !namespaces || namespaces === '*') {\n return true\n }\n // Namespace splitting logic is based the 'debug' package implementation:\n // https://github.com/debug-js/debug/blob/4.4.1/src/common.js#L169-L173.\n const split = namespaces\n .trim()\n .replace(/\\s+/g, ',')\n .split(',')\n .filter(Boolean)\n const names = []\n const skips = []\n for (const ns of split) {\n if (ns.startsWith('-')) {\n skips.push(ns.slice(1))\n } else {\n names.push(ns)\n }\n }\n if (names.length && !names.some(ns => getDebugJsInstance(ns).enabled)) {\n return false\n }\n return skips.every(ns => !getDebugJsInstance(ns).enabled)\n}\n\n/**\n * Debug output for object inspection with caller info.\n */\nfunction debugDirNs(\n namespacesOrOpts: NamespacesOrOptions,\n obj: unknown,\n inspectOpts?: InspectOptions | undefined,\n) {\n const options = extractOptions(namespacesOrOpts)\n const { namespaces } = options\n if (!isEnabled(namespaces as string)) {\n return\n }\n // Get caller info with stack offset of 4 (caller -> debugDirNs -> getCallerInfo).\n const callerName = getCallerInfo(4) || 'anonymous'\n\n if (pointingTriangle === undefined) {\n const supported = isUnicodeSupported()\n pointingTriangle = supported ? '\u25B8' : '>'\n }\n\n let opts: InspectOptions | undefined = inspectOpts\n if (opts === undefined) {\n const debugOpts = debugJs.inspectOpts\n if (debugOpts) {\n opts = {\n ...debugOpts,\n showHidden:\n debugOpts.showHidden === null ? undefined : debugOpts.showHidden,\n depth:\n debugOpts.depth === null || typeof debugOpts.depth === 'boolean'\n ? null\n : debugOpts.depth,\n } as InspectOptions\n }\n }\n const spinnerInstance = options.spinner || getSpinner()\n const wasSpinning = spinnerInstance?.isSpinning\n spinnerInstance?.stop()\n logger.info(`[DEBUG] ${callerName} ${pointingTriangle} object inspection:`)\n logger.dir(obj, inspectOpts)\n if (wasSpinning) {\n spinnerInstance?.start()\n }\n}\n\nlet pointingTriangle: string | undefined\n/**\n * Debug output with caller info.\n */\nfunction debugNs(namespacesOrOpts: NamespacesOrOptions, ...args: unknown[]) {\n const options = extractOptions(namespacesOrOpts)\n const { namespaces } = options\n if (!isEnabled(namespaces as string)) {\n return\n }\n // Get caller info with stack offset of 4 (caller -> debugNs -> getCallerInfo).\n const name = getCallerInfo(4) || 'anonymous'\n if (pointingTriangle === undefined) {\n const supported = isUnicodeSupported()\n pointingTriangle = supported ? '\u25B8' : '>'\n }\n const text = args.at(0)\n const logArgs =\n typeof text === 'string'\n ? [\n applyLinePrefix(\n `${name ? `${name} ${pointingTriangle} ` : ''}${text}`,\n { prefix: '[DEBUG] ' },\n ),\n ...args.slice(1),\n ]\n : args\n const spinnerInstance = options.spinner || getSpinner()\n const wasSpinning = spinnerInstance?.isSpinning\n spinnerInstance?.stop()\n ReflectApply(logger.info, logger, logArgs)\n if (wasSpinning) {\n spinnerInstance?.start()\n }\n}\n\n/**\n * Debug logging function with caller info.\n */\nfunction debugLogNs(namespacesOrOpts: NamespacesOrOptions, ...args: unknown[]) {\n const options = extractOptions(namespacesOrOpts)\n const { namespaces } = options\n if (!isEnabled(namespaces as string)) {\n return\n }\n // Get caller info with stack offset of 4 (caller -> debugLogNs -> getCallerInfo).\n const callerName = getCallerInfo(4) || 'anonymous'\n\n if (pointingTriangle === undefined) {\n const supported = isUnicodeSupported()\n pointingTriangle = supported ? '\u25B8' : '>'\n }\n\n const text = args.at(0)\n const logArgs =\n typeof text === 'string'\n ? [\n applyLinePrefix(\n `${callerName ? `${callerName} ${pointingTriangle} ` : ''}${text}`,\n { prefix: '[DEBUG] ' },\n ),\n ...args.slice(1),\n ]\n : [`[DEBUG] ${callerName} ${pointingTriangle}`, ...args]\n\n const spinnerInstance = options.spinner || getSpinner()\n const wasSpinning = spinnerInstance?.isSpinning\n spinnerInstance?.stop()\n ReflectApply(logger.info, logger, logArgs)\n if (wasSpinning) {\n spinnerInstance?.start()\n }\n}\n\n/**\n * Debug output for cache operations with caller info.\n * First argument is the operation type (hit/miss/set/clear).\n * Second argument is the cache key or message.\n * Optional third argument is metadata object.\n */\nfunction debugCacheNs(\n namespacesOrOpts: NamespacesOrOptions,\n operation: string,\n key: string,\n meta?: unknown | undefined,\n) {\n const options = extractOptions(namespacesOrOpts)\n const { namespaces } = options\n if (!isEnabled(namespaces as string)) {\n return\n }\n // Get caller info with stack offset of 4 (caller -> debugCacheNs -> getCallerInfo).\n const callerName = getCallerInfo(4) || 'cache'\n\n if (pointingTriangle === undefined) {\n const supported = isUnicodeSupported()\n pointingTriangle = supported ? '\u25B8' : '>'\n }\n\n const prefix = `[CACHE] ${callerName} ${pointingTriangle} ${operation}: ${key}`\n const logArgs = meta !== undefined ? [prefix, meta] : [prefix]\n\n const spinnerInstance = options.spinner || getSpinner()\n const wasSpinning = spinnerInstance?.isSpinning\n spinnerInstance?.stop()\n ReflectApply(logger.info, logger, logArgs)\n if (wasSpinning) {\n spinnerInstance?.start()\n }\n}\n\n/**\n * Cache debug function with caller info.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function debugCache(\n operation: string,\n key: string,\n meta?: unknown | undefined,\n): void {\n if (!getSocketDebug()) {\n return\n }\n // Get caller info with stack offset of 3 (caller -> debugCache -> getCallerInfo).\n const callerName = getCallerInfo(3) || 'cache'\n\n if (pointingTriangle === undefined) {\n const supported = isUnicodeSupported()\n pointingTriangle = supported ? '\u25B8' : '>'\n }\n\n const prefix = `[CACHE] ${callerName} ${pointingTriangle} ${operation}: ${key}`\n const args = meta !== undefined ? [prefix, meta] : [prefix]\n console.log(...args)\n}\n\n/**\n * Check if debug mode is enabled.\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction isDebugNs(namespaces: string | undefined): boolean {\n return !!getSocketDebug() && isEnabled(namespaces)\n}\n\n/**\n * Debug output with caller info (wrapper for debugNs with default namespace).\n */\nfunction debug(...args: unknown[]): void {\n debugNs('*', ...args)\n}\n\n/**\n * Debug output for object inspection (wrapper for debugDirNs with default namespace).\n */\nfunction debugDir(\n obj: unknown,\n inspectOpts?: InspectOptions | undefined,\n): void {\n debugDirNs('*', obj, inspectOpts)\n}\n\n/**\n * Debug logging function (wrapper for debugLogNs with default namespace).\n */\nfunction debugLog(...args: unknown[]): void {\n debugLogNs('*', ...args)\n}\n\n/**\n * Check if debug mode is enabled.\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction isDebug(): boolean {\n return !!getSocketDebug()\n}\n\n/**\n * Create a Node.js util.debuglog compatible function.\n * Returns a function that conditionally writes debug messages to stderr.\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction debuglog(section: string) {\n const util = getUtil()\n return util.debuglog(section)\n}\n\n/**\n * Create timing functions for measuring code execution time.\n * Returns an object with start() and end() methods, plus a callable function.\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction debugtime(label: string) {\n const util = getUtil()\n // Node.js util doesn't have debugtime - create a custom implementation\n let startTime: number | undefined\n const impl = () => {\n if (startTime === undefined) {\n startTime = Date.now()\n } else {\n const duration = Date.now() - startTime\n util.debuglog('time')(`${label}: ${duration}ms`)\n startTime = undefined\n }\n }\n impl.start = () => {\n startTime = Date.now()\n }\n impl.end = () => {\n if (startTime !== undefined) {\n const duration = Date.now() - startTime\n util.debuglog('time')(`${label}: ${duration}ms`)\n startTime = undefined\n }\n }\n return impl\n}\n\n// Export main debug functions with caller info.\nexport { debug }\n// debugCache is already exported directly above\nexport { debugCacheNs }\nexport { debugDir }\nexport { debugDirNs }\nexport { debugLog }\nexport { debuglog }\nexport { debugLogNs }\nexport { debugNs }\nexport { debugtime }\nexport { isDebug }\nexport { isDebugNs }\n"],
|
|
5
|
-
"mappings": ";6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,WAAAE,EAAA,eAAAC,EAAA,iBAAAC,EAAA,aAAAC,EAAA,eAAAC,EAAA,aAAAC,EAAA,eAAAC,EAAA,YAAAC,EAAA,aAAAC,EAAA,cAAAC,EAAA,YAAAC,EAAA,cAAAC,IAAA,eAAAC,EAAAd,GAKA,IAAAe,EAA2B,8BAC3BC,EAAyB,sBACzBC,EAA+B,uBAC/BC,EAA+B,8DAC/BF,EAAoB,+BAEpBG,
|
|
6
|
-
"names": ["debug_exports", "__export", "debug", "debugCache", "debugCacheNs", "debugDir", "debugDirNs", "debugLog", "debugLogNs", "debugNs", "debuglog", "debugtime", "isDebug", "isDebugNs", "__toCommonJS", "import_process", "import_debug", "import_socket", "import_is_unicode_supported", "import_logger", "import_objects", "import_strings", "ReflectApply", "debugByNamespace", "getDebugJsInstance", "namespace", "inst", "debugJs", "customLog", "_util", "getUtil", "getCallerInfo", "stackOffset", "name", "captureStackTrace", "obj", "stack", "lineCount", "lineStart", "i", "length", "line", "match", "afterDot", "args", "util", "inspectOpts", "extractOptions", "namespaces", "isEnabled", "split", "names", "skips", "ns", "namespacesOrOpts", "options", "callerName", "pointingTriangle", "isUnicodeSupported", "opts", "debugOpts", "spinnerInstance", "wasSpinning", "text", "logArgs", "operation", "key", "meta", "prefix", "section", "label", "startTime", "impl", "duration"]
|
|
4
|
+
"sourcesContent": ["/**\n * @fileoverview Debug logging utilities with lazy loading and environment-based control.\n * Provides Socket CLI specific debug functionality and logging formatters.\n */\n\nimport { getSpinner } from '#constants/process'\nimport { getDebug } from '#env/debug'\nimport { getSocketDebug } from '#env/socket'\nimport isUnicodeSupported from './external/@socketregistry/is-unicode-supported'\nimport debugJs from './external/debug'\n\nimport { getDefaultLogger } from './logger'\nimport { hasOwn } from './objects'\nimport { applyLinePrefix } from './strings'\n\nconst logger = getDefaultLogger()\n\n// IMPORTANT: Do not use destructuring here - use direct assignment instead.\n// tsgo has a bug that incorrectly transpiles destructured exports, resulting in\n// `exports.SomeName = void 0;` which causes runtime errors.\n// See: https://github.com/SocketDev/socket-packageurl-js/issues/3\nconst ReflectApply = Reflect.apply\n\n// Type definitions\ninterface DebugOptions {\n namespaces?: string\n spinner?: { isSpinning: boolean; stop(): void; start(): void }\n [key: string]: unknown\n}\n\ntype NamespacesOrOptions = string | DebugOptions\n\ninterface InspectOptions {\n depth?: number | null\n colors?: boolean\n [key: string]: unknown\n}\n\nexport type { DebugOptions, NamespacesOrOptions, InspectOptions }\n\nconst debugByNamespace = new Map()\n/**\n * Get or create a debug instance for a namespace.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getDebugJsInstance(namespace: string) {\n let inst = debugByNamespace.get(namespace)\n if (inst) {\n return inst\n }\n if (\n !getDebug() &&\n getSocketDebug() &&\n (namespace === 'error' || namespace === 'notice')\n ) {\n debugJs.enable(namespace)\n }\n inst = debugJs(namespace)\n inst.log = customLog\n debugByNamespace.set(namespace, inst)\n return inst\n}\n\nlet _util: typeof import('util') | undefined\n/**\n * Lazily load the util module.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getUtil() {\n if (_util === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _util = /*@__PURE__*/ require('node:util')\n }\n return _util as typeof import('util')\n}\n\n/**\n * Extract caller information from the stack trace.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getCallerInfo(stackOffset: number = 3): string {\n let name = ''\n const captureStackTrace = Error.captureStackTrace\n if (typeof captureStackTrace === 'function') {\n const obj: { stack?: unknown } = {}\n captureStackTrace(obj, getCallerInfo)\n const stack = obj.stack\n if (typeof stack === 'string') {\n let lineCount = 0\n let lineStart = 0\n for (let i = 0, { length } = stack; i < length; i += 1) {\n if (stack[i] === '\\n') {\n lineCount += 1\n if (lineCount < stackOffset) {\n // Store the start index of the next line.\n lineStart = i + 1\n } else {\n // Extract the full line and trim it.\n const line = stack.slice(lineStart, i).trimStart()\n // Match the function name portion (e.g., \"async runFix\").\n const match = /(?<=^at\\s+).*?(?=\\s+\\(|$)/.exec(line)?.[0]\n if (match) {\n name = match\n // Strip known V8 invocation prefixes to get the name.\n .replace(/^(?:async|bound|get|new|set)\\s+/, '')\n if (name.startsWith('Object.')) {\n // Strip leading 'Object.' if not an own property of Object.\n const afterDot = name.slice(7 /*'Object.'.length*/)\n if (!hasOwn(Object, afterDot)) {\n name = afterDot\n }\n }\n }\n break\n }\n }\n }\n }\n }\n return name\n}\n\n/**\n * Custom log function for debug output.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction customLog(...args: unknown[]) {\n const util = getUtil()\n const inspectOpts = debugJs.inspectOpts\n ? {\n ...debugJs.inspectOpts,\n showHidden:\n debugJs.inspectOpts.showHidden === null\n ? undefined\n : debugJs.inspectOpts.showHidden,\n depth:\n debugJs.inspectOpts.depth === null ||\n typeof debugJs.inspectOpts.depth === 'boolean'\n ? undefined\n : debugJs.inspectOpts.depth,\n }\n : {}\n ReflectApply(logger.info, logger, [\n util.formatWithOptions(inspectOpts, ...args),\n ])\n}\n\n/**\n * Extract options from namespaces parameter.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction extractOptions(namespaces: NamespacesOrOptions): DebugOptions {\n return namespaces !== null && typeof namespaces === 'object'\n ? ({ __proto__: null, ...namespaces } as DebugOptions)\n : ({ __proto__: null, namespaces } as DebugOptions)\n}\n\n/**\n * Check if debug is enabled for given namespaces.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction isEnabled(namespaces: string | undefined) {\n // Check if debugging is enabled at all\n if (!getSocketDebug()) {\n return false\n }\n if (typeof namespaces !== 'string' || !namespaces || namespaces === '*') {\n return true\n }\n // Namespace splitting logic is based the 'debug' package implementation:\n // https://github.com/debug-js/debug/blob/4.4.1/src/common.js#L169-L173.\n const split = namespaces\n .trim()\n .replace(/\\s+/g, ',')\n .split(',')\n .filter(Boolean)\n const names = []\n const skips = []\n for (const ns of split) {\n if (ns.startsWith('-')) {\n skips.push(ns.slice(1))\n } else {\n names.push(ns)\n }\n }\n if (names.length && !names.some(ns => getDebugJsInstance(ns).enabled)) {\n return false\n }\n return skips.every(ns => !getDebugJsInstance(ns).enabled)\n}\n\n/**\n * Debug output for object inspection with caller info.\n */\nfunction debugDirNs(\n namespacesOrOpts: NamespacesOrOptions,\n obj: unknown,\n inspectOpts?: InspectOptions | undefined,\n) {\n const options = extractOptions(namespacesOrOpts)\n const { namespaces } = options\n if (!isEnabled(namespaces as string)) {\n return\n }\n // Get caller info with stack offset of 4 (caller -> debugDirNs -> getCallerInfo).\n const callerName = getCallerInfo(4) || 'anonymous'\n\n if (pointingTriangle === undefined) {\n const supported = isUnicodeSupported()\n pointingTriangle = supported ? '\u25B8' : '>'\n }\n\n let opts: InspectOptions | undefined = inspectOpts\n if (opts === undefined) {\n const debugOpts = debugJs.inspectOpts\n if (debugOpts) {\n opts = {\n ...debugOpts,\n showHidden:\n debugOpts.showHidden === null ? undefined : debugOpts.showHidden,\n depth:\n debugOpts.depth === null || typeof debugOpts.depth === 'boolean'\n ? null\n : debugOpts.depth,\n } as InspectOptions\n }\n }\n const spinnerInstance = options.spinner || getSpinner()\n const wasSpinning = spinnerInstance?.isSpinning\n spinnerInstance?.stop()\n logger.info(`[DEBUG] ${callerName} ${pointingTriangle} object inspection:`)\n logger.dir(obj, inspectOpts)\n if (wasSpinning) {\n spinnerInstance?.start()\n }\n}\n\nlet pointingTriangle: string | undefined\n/**\n * Debug output with caller info.\n */\nfunction debugNs(namespacesOrOpts: NamespacesOrOptions, ...args: unknown[]) {\n const options = extractOptions(namespacesOrOpts)\n const { namespaces } = options\n if (!isEnabled(namespaces as string)) {\n return\n }\n // Get caller info with stack offset of 4 (caller -> debugNs -> getCallerInfo).\n const name = getCallerInfo(4) || 'anonymous'\n if (pointingTriangle === undefined) {\n const supported = isUnicodeSupported()\n pointingTriangle = supported ? '\u25B8' : '>'\n }\n const text = args.at(0)\n const logArgs =\n typeof text === 'string'\n ? [\n applyLinePrefix(\n `${name ? `${name} ${pointingTriangle} ` : ''}${text}`,\n { prefix: '[DEBUG] ' },\n ),\n ...args.slice(1),\n ]\n : args\n const spinnerInstance = options.spinner || getSpinner()\n const wasSpinning = spinnerInstance?.isSpinning\n spinnerInstance?.stop()\n ReflectApply(logger.info, logger, logArgs)\n if (wasSpinning) {\n spinnerInstance?.start()\n }\n}\n\n/**\n * Debug logging function with caller info.\n */\nfunction debugLogNs(namespacesOrOpts: NamespacesOrOptions, ...args: unknown[]) {\n const options = extractOptions(namespacesOrOpts)\n const { namespaces } = options\n if (!isEnabled(namespaces as string)) {\n return\n }\n // Get caller info with stack offset of 4 (caller -> debugLogNs -> getCallerInfo).\n const callerName = getCallerInfo(4) || 'anonymous'\n\n if (pointingTriangle === undefined) {\n const supported = isUnicodeSupported()\n pointingTriangle = supported ? '\u25B8' : '>'\n }\n\n const text = args.at(0)\n const logArgs =\n typeof text === 'string'\n ? [\n applyLinePrefix(\n `${callerName ? `${callerName} ${pointingTriangle} ` : ''}${text}`,\n { prefix: '[DEBUG] ' },\n ),\n ...args.slice(1),\n ]\n : [`[DEBUG] ${callerName} ${pointingTriangle}`, ...args]\n\n const spinnerInstance = options.spinner || getSpinner()\n const wasSpinning = spinnerInstance?.isSpinning\n spinnerInstance?.stop()\n ReflectApply(logger.info, logger, logArgs)\n if (wasSpinning) {\n spinnerInstance?.start()\n }\n}\n\n/**\n * Debug output for cache operations with caller info.\n * First argument is the operation type (hit/miss/set/clear).\n * Second argument is the cache key or message.\n * Optional third argument is metadata object.\n */\nfunction debugCacheNs(\n namespacesOrOpts: NamespacesOrOptions,\n operation: string,\n key: string,\n meta?: unknown | undefined,\n) {\n const options = extractOptions(namespacesOrOpts)\n const { namespaces } = options\n if (!isEnabled(namespaces as string)) {\n return\n }\n // Get caller info with stack offset of 4 (caller -> debugCacheNs -> getCallerInfo).\n const callerName = getCallerInfo(4) || 'cache'\n\n if (pointingTriangle === undefined) {\n const supported = isUnicodeSupported()\n pointingTriangle = supported ? '\u25B8' : '>'\n }\n\n const prefix = `[CACHE] ${callerName} ${pointingTriangle} ${operation}: ${key}`\n const logArgs = meta !== undefined ? [prefix, meta] : [prefix]\n\n const spinnerInstance = options.spinner || getSpinner()\n const wasSpinning = spinnerInstance?.isSpinning\n spinnerInstance?.stop()\n ReflectApply(logger.info, logger, logArgs)\n if (wasSpinning) {\n spinnerInstance?.start()\n }\n}\n\n/**\n * Cache debug function with caller info.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function debugCache(\n operation: string,\n key: string,\n meta?: unknown | undefined,\n): void {\n if (!getSocketDebug()) {\n return\n }\n // Get caller info with stack offset of 3 (caller -> debugCache -> getCallerInfo).\n const callerName = getCallerInfo(3) || 'cache'\n\n if (pointingTriangle === undefined) {\n const supported = isUnicodeSupported()\n pointingTriangle = supported ? '\u25B8' : '>'\n }\n\n const prefix = `[CACHE] ${callerName} ${pointingTriangle} ${operation}: ${key}`\n const args = meta !== undefined ? [prefix, meta] : [prefix]\n console.log(...args)\n}\n\n/**\n * Check if debug mode is enabled.\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction isDebugNs(namespaces: string | undefined): boolean {\n return !!getSocketDebug() && isEnabled(namespaces)\n}\n\n/**\n * Debug output with caller info (wrapper for debugNs with default namespace).\n */\nfunction debug(...args: unknown[]): void {\n debugNs('*', ...args)\n}\n\n/**\n * Debug output for object inspection (wrapper for debugDirNs with default namespace).\n */\nfunction debugDir(\n obj: unknown,\n inspectOpts?: InspectOptions | undefined,\n): void {\n debugDirNs('*', obj, inspectOpts)\n}\n\n/**\n * Debug logging function (wrapper for debugLogNs with default namespace).\n */\nfunction debugLog(...args: unknown[]): void {\n debugLogNs('*', ...args)\n}\n\n/**\n * Check if debug mode is enabled.\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction isDebug(): boolean {\n return !!getSocketDebug()\n}\n\n/**\n * Create a Node.js util.debuglog compatible function.\n * Returns a function that conditionally writes debug messages to stderr.\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction debuglog(section: string) {\n const util = getUtil()\n return util.debuglog(section)\n}\n\n/**\n * Create timing functions for measuring code execution time.\n * Returns an object with start() and end() methods, plus a callable function.\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction debugtime(label: string) {\n const util = getUtil()\n // Node.js util doesn't have debugtime - create a custom implementation\n let startTime: number | undefined\n const impl = () => {\n if (startTime === undefined) {\n startTime = Date.now()\n } else {\n const duration = Date.now() - startTime\n util.debuglog('time')(`${label}: ${duration}ms`)\n startTime = undefined\n }\n }\n impl.start = () => {\n startTime = Date.now()\n }\n impl.end = () => {\n if (startTime !== undefined) {\n const duration = Date.now() - startTime\n util.debuglog('time')(`${label}: ${duration}ms`)\n startTime = undefined\n }\n }\n return impl\n}\n\n// Export main debug functions with caller info.\nexport { debug }\n// debugCache is already exported directly above\nexport { debugCacheNs }\nexport { debugDir }\nexport { debugDirNs }\nexport { debugLog }\nexport { debuglog }\nexport { debugLogNs }\nexport { debugNs }\nexport { debugtime }\nexport { isDebug }\nexport { isDebugNs }\n"],
|
|
5
|
+
"mappings":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E,GAAGyB,CAAK,KAAKG,CAAQ,IAAI,EAC/CF,EAAY,MACd,CACF,EACA,OAAAC,EAAK,MAAQ,IAAM,CACjBD,EAAY,KAAK,IAAI,CACvB,EACAC,EAAK,IAAM,IAAM,CACf,GAAID,IAAc,OAAW,CAC3B,MAAME,EAAW,KAAK,IAAI,EAAIF,EAC9B1B,EAAK,SAAS,MAAM,EAAE,GAAGyB,CAAK,KAAKG,CAAQ,IAAI,EAC/CF,EAAY,MACd,CACF,EACOC,CACT",
|
|
6
|
+
"names": ["debug_exports", "__export", "debug", "debugCache", "debugCacheNs", "debugDir", "debugDirNs", "debugLog", "debugLogNs", "debugNs", "debuglog", "debugtime", "isDebug", "isDebugNs", "__toCommonJS", "import_process", "import_debug", "import_socket", "import_is_unicode_supported", "import_logger", "import_objects", "import_strings", "logger", "ReflectApply", "debugByNamespace", "getDebugJsInstance", "namespace", "inst", "debugJs", "customLog", "_util", "getUtil", "getCallerInfo", "stackOffset", "name", "captureStackTrace", "obj", "stack", "lineCount", "lineStart", "i", "length", "line", "match", "afterDot", "args", "util", "inspectOpts", "extractOptions", "namespaces", "isEnabled", "split", "names", "skips", "ns", "namespacesOrOpts", "options", "callerName", "pointingTriangle", "isUnicodeSupported", "opts", "debugOpts", "spinnerInstance", "wasSpinning", "text", "logArgs", "operation", "key", "meta", "prefix", "section", "label", "startTime", "impl", "duration"]
|
|
7
7
|
}
|