@socketsecurity/lib 1.3.5 → 2.1.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 +84 -0
- package/dist/agent.js +1 -1
- package/dist/agent.js.map +2 -2
- package/dist/bin.js +1 -1
- package/dist/bin.js.map +3 -3
- package/dist/cacache.d.ts +4 -0
- package/dist/cacache.js +1 -1
- package/dist/cacache.js.map +3 -3
- package/dist/constants/packages.js +1 -1
- package/dist/constants/packages.js.map +3 -3
- package/dist/debug.d.ts +0 -7
- package/dist/debug.js +2 -2
- package/dist/debug.js.map +3 -3
- package/dist/dlx-binary.js +1 -1
- package/dist/dlx-binary.js.map +3 -3
- package/dist/dlx-package.d.ts +51 -0
- package/dist/dlx-package.js +1 -1
- package/dist/dlx-package.js.map +3 -3
- package/dist/dlx.d.ts +15 -0
- package/dist/dlx.js +1 -1
- package/dist/dlx.js.map +3 -3
- package/dist/effects/text-shimmer.js +1 -1
- package/dist/effects/text-shimmer.js.map +2 -2
- package/dist/env/ci.d.ts +1 -1
- package/dist/env/ci.js +1 -1
- package/dist/env/ci.js.map +3 -3
- package/dist/env/debug.d.ts +1 -1
- package/dist/env/debug.js +1 -1
- package/dist/env/debug.js.map +3 -3
- package/dist/env/github.d.ts +40 -0
- package/dist/env/github.js +3 -0
- package/dist/env/github.js.map +7 -0
- package/dist/env/home.d.ts +1 -1
- package/dist/env/home.js +1 -1
- package/dist/env/home.js.map +3 -3
- package/dist/env/locale.d.ts +15 -0
- package/dist/env/locale.js +3 -0
- package/dist/env/locale.js.map +7 -0
- package/dist/env/node-auth-token.d.ts +1 -1
- package/dist/env/node-auth-token.js +1 -1
- package/dist/env/node-auth-token.js.map +3 -3
- package/dist/env/node-env.d.ts +1 -1
- package/dist/env/node-env.js +1 -1
- package/dist/env/node-env.js.map +3 -3
- package/dist/env/npm.d.ts +25 -0
- package/dist/env/npm.js +3 -0
- package/dist/env/npm.js.map +7 -0
- package/dist/env/package-manager.d.ts +58 -0
- package/dist/env/package-manager.js +3 -0
- package/dist/env/package-manager.js.map +7 -0
- package/dist/env/path.d.ts +1 -1
- package/dist/env/path.js +1 -1
- package/dist/env/path.js.map +3 -3
- package/dist/env/pre-commit.d.ts +1 -1
- package/dist/env/pre-commit.js +1 -1
- package/dist/env/pre-commit.js.map +3 -3
- package/dist/env/rewire.d.ts +106 -0
- package/dist/env/rewire.js +3 -0
- package/dist/env/rewire.js.map +7 -0
- package/dist/env/shell.d.ts +1 -1
- package/dist/env/shell.js +1 -1
- package/dist/env/shell.js.map +3 -3
- package/dist/env/socket-cli-shadow.d.ts +30 -0
- package/dist/env/socket-cli-shadow.js +3 -0
- package/dist/env/socket-cli-shadow.js.map +7 -0
- package/dist/env/socket-cli.d.ts +72 -0
- package/dist/env/socket-cli.js +3 -0
- package/dist/env/socket-cli.js.map +7 -0
- package/dist/env/socket.d.ts +75 -0
- package/dist/env/socket.js +3 -0
- package/dist/env/socket.js.map +7 -0
- package/dist/env/temp-dir.d.ts +15 -0
- package/dist/env/temp-dir.js +3 -0
- package/dist/env/temp-dir.js.map +7 -0
- package/dist/env/term.d.ts +1 -1
- package/dist/env/term.js +1 -1
- package/dist/env/term.js.map +3 -3
- package/dist/env/test.d.ts +15 -0
- package/dist/env/test.js +3 -0
- package/dist/env/test.js.map +7 -0
- package/dist/env/windows.d.ts +20 -0
- package/dist/env/windows.js +3 -0
- package/dist/env/windows.js.map +7 -0
- package/dist/env/xdg.d.ts +15 -0
- package/dist/env/xdg.js +3 -0
- package/dist/env/xdg.js.map +7 -0
- package/dist/fs.d.ts +7 -0
- package/dist/fs.js +3 -3
- package/dist/fs.js.map +3 -3
- package/dist/github.js +1 -1
- package/dist/github.js.map +3 -3
- package/dist/globs.js +1 -1
- package/dist/globs.js.map +2 -2
- package/dist/ipc.d.ts +1 -1
- package/dist/ipc.js +1 -1
- package/dist/ipc.js.map +3 -3
- package/dist/logger.d.ts +2 -1
- 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/packages/normalize.js +1 -1
- package/dist/packages/normalize.js.map +3 -3
- package/dist/packages/operations.js +1 -1
- package/dist/packages/operations.js.map +3 -3
- package/dist/path.d.ts +2 -2
- package/dist/path.js +1 -1
- package/dist/path.js.map +3 -3
- package/dist/paths/rewire.d.ts +71 -0
- package/dist/paths/rewire.js +3 -0
- package/dist/paths/rewire.js.map +7 -0
- package/dist/paths.d.ts +26 -0
- package/dist/paths.js +1 -1
- package/dist/paths.js.map +3 -3
- package/dist/spinner.js +1 -1
- package/dist/spinner.js.map +2 -2
- package/package.json +42 -225
- package/dist/env/appdata.d.ts +0 -1
- package/dist/env/appdata.js +0 -3
- package/dist/env/appdata.js.map +0 -7
- package/dist/env/comspec.d.ts +0 -1
- package/dist/env/comspec.js +0 -3
- package/dist/env/comspec.js.map +0 -7
- package/dist/env/getters.d.ts +0 -40
- package/dist/env/getters.js +0 -3
- package/dist/env/getters.js.map +0 -7
- package/dist/env/github-api-url.d.ts +0 -1
- package/dist/env/github-api-url.js +0 -3
- package/dist/env/github-api-url.js.map +0 -7
- package/dist/env/github-base-ref.d.ts +0 -1
- package/dist/env/github-base-ref.js +0 -3
- package/dist/env/github-base-ref.js.map +0 -7
- package/dist/env/github-ref-name.d.ts +0 -1
- package/dist/env/github-ref-name.js +0 -3
- package/dist/env/github-ref-name.js.map +0 -7
- package/dist/env/github-ref-type.d.ts +0 -1
- package/dist/env/github-ref-type.js +0 -3
- package/dist/env/github-ref-type.js.map +0 -7
- package/dist/env/github-repository.d.ts +0 -1
- package/dist/env/github-repository.js +0 -3
- package/dist/env/github-repository.js.map +0 -7
- package/dist/env/github-server-url.d.ts +0 -1
- package/dist/env/github-server-url.js +0 -3
- package/dist/env/github-server-url.js.map +0 -7
- package/dist/env/github-token.d.ts +0 -1
- package/dist/env/github-token.js +0 -3
- package/dist/env/github-token.js.map +0 -7
- package/dist/env/jest-worker-id.d.ts +0 -1
- package/dist/env/jest-worker-id.js +0 -3
- package/dist/env/jest-worker-id.js.map +0 -7
- package/dist/env/lang.d.ts +0 -1
- package/dist/env/lang.js +0 -3
- package/dist/env/lang.js.map +0 -7
- package/dist/env/lc-all.d.ts +0 -1
- package/dist/env/lc-all.js +0 -3
- package/dist/env/lc-all.js.map +0 -7
- package/dist/env/lc-messages.d.ts +0 -1
- package/dist/env/lc-messages.js +0 -3
- package/dist/env/lc-messages.js.map +0 -7
- package/dist/env/localappdata.d.ts +0 -1
- package/dist/env/localappdata.js +0 -3
- package/dist/env/localappdata.js.map +0 -7
- package/dist/env/npm-config-registry.d.ts +0 -1
- package/dist/env/npm-config-registry.js +0 -3
- package/dist/env/npm-config-registry.js.map +0 -7
- package/dist/env/npm-config-user-agent.d.ts +0 -1
- package/dist/env/npm-config-user-agent.js +0 -3
- package/dist/env/npm-config-user-agent.js.map +0 -7
- package/dist/env/npm-lifecycle-event.d.ts +0 -1
- package/dist/env/npm-lifecycle-event.js +0 -3
- package/dist/env/npm-lifecycle-event.js.map +0 -7
- package/dist/env/npm-registry.d.ts +0 -1
- package/dist/env/npm-registry.js +0 -3
- package/dist/env/npm-registry.js.map +0 -7
- package/dist/env/npm-token.d.ts +0 -1
- package/dist/env/npm-token.js +0 -3
- package/dist/env/npm-token.js.map +0 -7
- package/dist/env/socket-accept-risks.d.ts +0 -1
- package/dist/env/socket-accept-risks.js +0 -3
- package/dist/env/socket-accept-risks.js.map +0 -7
- package/dist/env/socket-api-base-url.d.ts +0 -1
- package/dist/env/socket-api-base-url.js +0 -3
- package/dist/env/socket-api-base-url.js.map +0 -7
- package/dist/env/socket-api-proxy.d.ts +0 -1
- package/dist/env/socket-api-proxy.js +0 -3
- package/dist/env/socket-api-proxy.js.map +0 -7
- package/dist/env/socket-api-timeout.d.ts +0 -1
- package/dist/env/socket-api-timeout.js +0 -3
- package/dist/env/socket-api-timeout.js.map +0 -7
- package/dist/env/socket-api-token.d.ts +0 -1
- package/dist/env/socket-api-token.js +0 -3
- package/dist/env/socket-api-token.js.map +0 -7
- package/dist/env/socket-cacache-dir.d.ts +0 -1
- package/dist/env/socket-cacache-dir.js +0 -3
- package/dist/env/socket-cacache-dir.js.map +0 -7
- package/dist/env/socket-cli-accept-risks.d.ts +0 -1
- package/dist/env/socket-cli-accept-risks.js +0 -3
- package/dist/env/socket-cli-accept-risks.js.map +0 -7
- package/dist/env/socket-cli-api-base-url.d.ts +0 -1
- package/dist/env/socket-cli-api-base-url.js +0 -3
- package/dist/env/socket-cli-api-base-url.js.map +0 -7
- package/dist/env/socket-cli-api-proxy.d.ts +0 -1
- package/dist/env/socket-cli-api-proxy.js +0 -3
- package/dist/env/socket-cli-api-proxy.js.map +0 -7
- package/dist/env/socket-cli-api-timeout.d.ts +0 -1
- package/dist/env/socket-cli-api-timeout.js +0 -3
- package/dist/env/socket-cli-api-timeout.js.map +0 -7
- package/dist/env/socket-cli-api-token.d.ts +0 -1
- package/dist/env/socket-cli-api-token.js +0 -3
- package/dist/env/socket-cli-api-token.js.map +0 -7
- package/dist/env/socket-cli-config.d.ts +0 -1
- package/dist/env/socket-cli-config.js +0 -3
- package/dist/env/socket-cli-config.js.map +0 -7
- package/dist/env/socket-cli-fix.d.ts +0 -1
- package/dist/env/socket-cli-fix.js +0 -3
- package/dist/env/socket-cli-fix.js.map +0 -7
- package/dist/env/socket-cli-no-api-token.d.ts +0 -1
- package/dist/env/socket-cli-no-api-token.js +0 -3
- package/dist/env/socket-cli-no-api-token.js.map +0 -7
- package/dist/env/socket-cli-optimize.d.ts +0 -1
- package/dist/env/socket-cli-optimize.js +0 -3
- package/dist/env/socket-cli-optimize.js.map +0 -7
- package/dist/env/socket-cli-org-slug.d.ts +0 -1
- package/dist/env/socket-cli-org-slug.js +0 -3
- package/dist/env/socket-cli-org-slug.js.map +0 -7
- package/dist/env/socket-cli-shadow-accept-risks.d.ts +0 -1
- package/dist/env/socket-cli-shadow-accept-risks.js +0 -3
- package/dist/env/socket-cli-shadow-accept-risks.js.map +0 -7
- package/dist/env/socket-cli-shadow-api-token.d.ts +0 -1
- package/dist/env/socket-cli-shadow-api-token.js +0 -3
- package/dist/env/socket-cli-shadow-api-token.js.map +0 -7
- package/dist/env/socket-cli-shadow-bin.d.ts +0 -1
- package/dist/env/socket-cli-shadow-bin.js +0 -3
- package/dist/env/socket-cli-shadow-bin.js.map +0 -7
- package/dist/env/socket-cli-shadow-progress.d.ts +0 -1
- package/dist/env/socket-cli-shadow-progress.js +0 -3
- package/dist/env/socket-cli-shadow-progress.js.map +0 -7
- package/dist/env/socket-cli-shadow-silent.d.ts +0 -1
- package/dist/env/socket-cli-shadow-silent.js +0 -3
- package/dist/env/socket-cli-shadow-silent.js.map +0 -7
- package/dist/env/socket-cli-view-all-risks.d.ts +0 -1
- package/dist/env/socket-cli-view-all-risks.js +0 -3
- package/dist/env/socket-cli-view-all-risks.js.map +0 -7
- package/dist/env/socket-config.d.ts +0 -1
- package/dist/env/socket-config.js +0 -3
- package/dist/env/socket-config.js.map +0 -7
- package/dist/env/socket-debug.d.ts +0 -1
- package/dist/env/socket-debug.js +0 -3
- package/dist/env/socket-debug.js.map +0 -7
- package/dist/env/socket-home.d.ts +0 -1
- package/dist/env/socket-home.js +0 -3
- package/dist/env/socket-home.js.map +0 -7
- package/dist/env/socket-no-api-token.d.ts +0 -1
- package/dist/env/socket-no-api-token.js +0 -3
- package/dist/env/socket-no-api-token.js.map +0 -7
- package/dist/env/socket-npm-registry.d.ts +0 -1
- package/dist/env/socket-npm-registry.js +0 -3
- package/dist/env/socket-npm-registry.js.map +0 -7
- package/dist/env/socket-org-slug.d.ts +0 -1
- package/dist/env/socket-org-slug.js +0 -3
- package/dist/env/socket-org-slug.js.map +0 -7
- package/dist/env/socket-registry-url.d.ts +0 -1
- package/dist/env/socket-registry-url.js +0 -3
- package/dist/env/socket-registry-url.js.map +0 -7
- package/dist/env/socket-view-all-risks.d.ts +0 -1
- package/dist/env/socket-view-all-risks.js +0 -3
- package/dist/env/socket-view-all-risks.js.map +0 -7
- package/dist/env/temp.d.ts +0 -1
- package/dist/env/temp.js +0 -3
- package/dist/env/temp.js.map +0 -7
- package/dist/env/tmp.d.ts +0 -1
- package/dist/env/tmp.js +0 -3
- package/dist/env/tmp.js.map +0 -7
- package/dist/env/tmpdir.d.ts +0 -1
- package/dist/env/tmpdir.js +0 -3
- package/dist/env/tmpdir.js.map +0 -7
- package/dist/env/userprofile.d.ts +0 -1
- package/dist/env/userprofile.js +0 -3
- package/dist/env/userprofile.js.map +0 -7
- package/dist/env/vitest.d.ts +0 -1
- package/dist/env/vitest.js +0 -3
- package/dist/env/vitest.js.map +0 -7
- package/dist/env/xdg-cache-home.d.ts +0 -1
- package/dist/env/xdg-cache-home.js +0 -3
- package/dist/env/xdg-cache-home.js.map +0 -7
- package/dist/env/xdg-config-home.d.ts +0 -1
- package/dist/env/xdg-config-home.js +0 -3
- package/dist/env/xdg-config-home.js.map +0 -7
- package/dist/env/xdg-data-home.d.ts +0 -1
- package/dist/env/xdg-data-home.js +0 -3
- package/dist/env/xdg-data-home.js.map +0 -7
package/dist/globs.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/globs.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * @fileoverview Glob pattern matching utilities with default ignore patterns.\n * Provides file filtering and glob matcher functions for npm-like behavior.\n */\n\n// IMPORTANT: Do not use destructuring here - use direct assignment instead.\nimport { objectFreeze as ObjectFreeze } from './objects'\n\n// Type definitions\ntype Pattern = string\n\ninterface FastGlobOptions {\n absolute?: boolean\n baseNameMatch?: boolean\n braceExpansion?: boolean\n caseSensitiveMatch?: boolean\n concurrency?: number\n cwd?: string\n deep?: number\n dot?: boolean\n extglob?: boolean\n followSymbolicLinks?: boolean\n fs?: unknown\n globstar?: boolean\n ignore?: string[]\n ignoreFiles?: string[]\n markDirectories?: boolean\n objectMode?: boolean\n onlyDirectories?: boolean\n onlyFiles?: boolean\n stats?: boolean\n suppressErrors?: boolean\n throwErrorOnBrokenSymbolicLink?: boolean\n unique?: boolean\n}\n\nexport interface GlobOptions extends FastGlobOptions {\n ignoreOriginals?: boolean\n recursive?: boolean\n}\n\nexport type { Pattern, FastGlobOptions }\n\nexport const defaultIgnore = ObjectFreeze([\n // Most of these ignored files can be included specifically if included in the\n // files globs. Exceptions to this are:\n // https://docs.npmjs.com/cli/v10/configuring-npm/package-json#files\n // These can NOT be included.\n // https://github.com/npm/npm-packlist/blob/v10.0.0/lib/index.js#L280\n '**/.git',\n '**/.npmrc',\n // '**/bun.lockb?',\n '**/node_modules',\n // '**/package-lock.json',\n // '**/pnpm-lock.ya?ml',\n // '**/yarn.lock',\n // Include npm-packlist defaults:\n // https://github.com/npm/npm-packlist/blob/v10.0.0/lib/index.js#L15-L38\n '**/.DS_Store',\n '**/.gitignore',\n '**/.hg',\n '**/.lock-wscript',\n '**/.npmignore',\n '**/.svn',\n '**/.wafpickle-*',\n '**/.*.swp',\n '**/._*/**',\n '**/archived-packages/**',\n '**/build/config.gypi',\n '**/CVS',\n '**/npm-debug.log',\n '**/*.orig',\n // Inline generic socket-registry .gitignore entries.\n '**/.env',\n '**/.eslintcache',\n '**/.nvm',\n '**/.tap',\n '**/.vscode',\n '**/*.tsbuildinfo',\n '**/Thumbs.db',\n // Inline additional ignores.\n '**/bower_components',\n])\n\nlet _picomatch: typeof import('picomatch') | undefined\n/**\n * Lazily load the picomatch module.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getPicomatch() {\n if (_picomatch === undefined) {\n // The 'picomatch' package is browser safe.\n _picomatch = /*@__PURE__*/ require('./external/picomatch')\n }\n return _picomatch as typeof import('picomatch')\n}\n\nlet _fastGlob: typeof import('fast-glob') | undefined\n/**\n * Lazily load the fast-glob module.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getFastGlob() {\n if (_fastGlob === undefined) {\n const globExport = /*@__PURE__*/ require('./external/fast-glob')\n _fastGlob = globExport.default || globExport\n }\n return _fastGlob as typeof import('fast-glob')\n}\n\n/**\n * Create a stream of license file paths matching glob patterns.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function globStreamLicenses(\n dirname: string,\n options?: GlobOptions,\n): NodeJS.ReadableStream {\n const {\n ignore: ignoreOpt,\n ignoreOriginals,\n recursive,\n ...globOptions\n } = { __proto__: null, ...options } as GlobOptions\n const ignore = [\n ...(Array.isArray(ignoreOpt) ? ignoreOpt : defaultIgnore),\n '**/*.{cjs,cts,js,json,mjs,mts,ts}',\n ]\n if (ignoreOriginals) {\n ignore.push(\n /*@__INLINE__*/ require('
|
|
5
|
-
"mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,EAAA,mBAAAC,EAAA,uBAAAC,IAAA,eAAAC,EAAAL,GAMA,IAAAM,EAA6C,qBAqCtC,MAAMJ,KAAgB,EAAAK,cAAa,CAMxC,UACA,YAEA,kBAMA,eACA,gBACA,SACA,mBACA,gBACA,UACA,kBACA,YACA,YACA,0BACA,uBACA,SACA,mBACA,YAEA,UACA,kBACA,UACA,UACA,aACA,mBACA,eAEA,qBACF,CAAC,EAED,IAAIC,EAMJ,SAASC,GAAe,CACtB,OAAID,IAAe,SAEjBA,EAA2B,QAAQ,sBAAsB,GAEpDA,CACT,CAEA,IAAIE,EAMJ,SAASC,GAAc,CACrB,GAAID,IAAc,OAAW,CAC3B,MAAME,EAA2B,QAAQ,sBAAsB,EAC/DF,EAAYE,EAAW,SAAWA,CACpC,CACA,OAAOF,CACT,CAMO,SAASN,EACdS,EACAC,EACuB,CACvB,KAAM,CACJ,OAAQC,EACR,gBAAAC,EACA,UAAAC,EACA,GAAGC,CACL,EAAI,CAAE,UAAW,KAAM,GAAGJ,CAAQ,EAC5BK,EAAS,CACb,GAAI,MAAM,QAAQJ,CAAS,EAAIA,EAAYb,EAC3C,mCACF,EACA,OAAIc,GACFG,EAAO,KACW,QAAQ,
|
|
4
|
+
"sourcesContent": ["/**\n * @fileoverview Glob pattern matching utilities with default ignore patterns.\n * Provides file filtering and glob matcher functions for npm-like behavior.\n */\n\n// IMPORTANT: Do not use destructuring here - use direct assignment instead.\nimport { objectFreeze as ObjectFreeze } from './objects'\n\n// Type definitions\ntype Pattern = string\n\ninterface FastGlobOptions {\n absolute?: boolean\n baseNameMatch?: boolean\n braceExpansion?: boolean\n caseSensitiveMatch?: boolean\n concurrency?: number\n cwd?: string\n deep?: number\n dot?: boolean\n extglob?: boolean\n followSymbolicLinks?: boolean\n fs?: unknown\n globstar?: boolean\n ignore?: string[]\n ignoreFiles?: string[]\n markDirectories?: boolean\n objectMode?: boolean\n onlyDirectories?: boolean\n onlyFiles?: boolean\n stats?: boolean\n suppressErrors?: boolean\n throwErrorOnBrokenSymbolicLink?: boolean\n unique?: boolean\n}\n\nexport interface GlobOptions extends FastGlobOptions {\n ignoreOriginals?: boolean\n recursive?: boolean\n}\n\nexport type { Pattern, FastGlobOptions }\n\nexport const defaultIgnore = ObjectFreeze([\n // Most of these ignored files can be included specifically if included in the\n // files globs. Exceptions to this are:\n // https://docs.npmjs.com/cli/v10/configuring-npm/package-json#files\n // These can NOT be included.\n // https://github.com/npm/npm-packlist/blob/v10.0.0/lib/index.js#L280\n '**/.git',\n '**/.npmrc',\n // '**/bun.lockb?',\n '**/node_modules',\n // '**/package-lock.json',\n // '**/pnpm-lock.ya?ml',\n // '**/yarn.lock',\n // Include npm-packlist defaults:\n // https://github.com/npm/npm-packlist/blob/v10.0.0/lib/index.js#L15-L38\n '**/.DS_Store',\n '**/.gitignore',\n '**/.hg',\n '**/.lock-wscript',\n '**/.npmignore',\n '**/.svn',\n '**/.wafpickle-*',\n '**/.*.swp',\n '**/._*/**',\n '**/archived-packages/**',\n '**/build/config.gypi',\n '**/CVS',\n '**/npm-debug.log',\n '**/*.orig',\n // Inline generic socket-registry .gitignore entries.\n '**/.env',\n '**/.eslintcache',\n '**/.nvm',\n '**/.tap',\n '**/.vscode',\n '**/*.tsbuildinfo',\n '**/Thumbs.db',\n // Inline additional ignores.\n '**/bower_components',\n])\n\nlet _picomatch: typeof import('picomatch') | undefined\n/**\n * Lazily load the picomatch module.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getPicomatch() {\n if (_picomatch === undefined) {\n // The 'picomatch' package is browser safe.\n _picomatch = /*@__PURE__*/ require('./external/picomatch')\n }\n return _picomatch as typeof import('picomatch')\n}\n\nlet _fastGlob: typeof import('fast-glob') | undefined\n/**\n * Lazily load the fast-glob module.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getFastGlob() {\n if (_fastGlob === undefined) {\n const globExport = /*@__PURE__*/ require('./external/fast-glob')\n _fastGlob = globExport.default || globExport\n }\n return _fastGlob as typeof import('fast-glob')\n}\n\n/**\n * Create a stream of license file paths matching glob patterns.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function globStreamLicenses(\n dirname: string,\n options?: GlobOptions,\n): NodeJS.ReadableStream {\n const {\n ignore: ignoreOpt,\n ignoreOriginals,\n recursive,\n ...globOptions\n } = { __proto__: null, ...options } as GlobOptions\n const ignore = [\n ...(Array.isArray(ignoreOpt) ? ignoreOpt : defaultIgnore),\n '**/*.{cjs,cts,js,json,mjs,mts,ts}',\n ]\n if (ignoreOriginals) {\n ignore.push(\n /*@__INLINE__*/ require('#constants/paths')\n .LICENSE_ORIGINAL_GLOB_RECURSIVE,\n )\n }\n const fastGlob = getFastGlob()\n return fastGlob.globStream(\n [\n recursive\n ? /*@__INLINE__*/ require('#constants/paths').LICENSE_GLOB_RECURSIVE\n : /*@__INLINE__*/ require('#constants/paths').LICENSE_GLOB,\n ],\n {\n __proto__: null,\n absolute: true,\n caseSensitiveMatch: false,\n cwd: dirname,\n ...globOptions,\n ...(ignore ? { ignore } : {}),\n } as import('fast-glob').Options,\n )\n}\n\nconst matcherCache = new Map()\n/**\n * Get a cached glob matcher function.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function getGlobMatcher(\n glob: Pattern | Pattern[],\n options?: { dot?: boolean; nocase?: boolean; ignore?: string[] },\n): (path: string) => boolean {\n const patterns = Array.isArray(glob) ? glob : [glob]\n const key = JSON.stringify({ patterns, options })\n let matcher = matcherCache.get(key)\n if (matcher) {\n return matcher\n }\n\n // Separate positive and negative patterns.\n const positivePatterns = patterns.filter(p => !p.startsWith('!'))\n const negativePatterns = patterns\n .filter(p => p.startsWith('!'))\n .map(p => p.slice(1))\n\n const picomatch = getPicomatch()\n\n // Use ignore option for negation patterns.\n const matchOptions = {\n dot: true,\n nocase: true,\n ...options,\n ...(negativePatterns.length > 0 ? { ignore: negativePatterns } : {}),\n }\n\n matcher = picomatch(\n positivePatterns.length > 0 ? positivePatterns : patterns,\n matchOptions,\n )\n\n matcherCache.set(key, matcher)\n return matcher\n}\n"],
|
|
5
|
+
"mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,EAAA,mBAAAC,EAAA,uBAAAC,IAAA,eAAAC,EAAAL,GAMA,IAAAM,EAA6C,qBAqCtC,MAAMJ,KAAgB,EAAAK,cAAa,CAMxC,UACA,YAEA,kBAMA,eACA,gBACA,SACA,mBACA,gBACA,UACA,kBACA,YACA,YACA,0BACA,uBACA,SACA,mBACA,YAEA,UACA,kBACA,UACA,UACA,aACA,mBACA,eAEA,qBACF,CAAC,EAED,IAAIC,EAMJ,SAASC,GAAe,CACtB,OAAID,IAAe,SAEjBA,EAA2B,QAAQ,sBAAsB,GAEpDA,CACT,CAEA,IAAIE,EAMJ,SAASC,GAAc,CACrB,GAAID,IAAc,OAAW,CAC3B,MAAME,EAA2B,QAAQ,sBAAsB,EAC/DF,EAAYE,EAAW,SAAWA,CACpC,CACA,OAAOF,CACT,CAMO,SAASN,EACdS,EACAC,EACuB,CACvB,KAAM,CACJ,OAAQC,EACR,gBAAAC,EACA,UAAAC,EACA,GAAGC,CACL,EAAI,CAAE,UAAW,KAAM,GAAGJ,CAAQ,EAC5BK,EAAS,CACb,GAAI,MAAM,QAAQJ,CAAS,EAAIA,EAAYb,EAC3C,mCACF,EACA,OAAIc,GACFG,EAAO,KACW,QAAQ,kBAAkB,EACvC,+BACL,EAEeR,EAAY,EACb,WACd,CACEM,EACoB,QAAQ,kBAAkB,EAAE,uBAC5B,QAAQ,kBAAkB,EAAE,YAClD,EACA,CACE,UAAW,KACX,SAAU,GACV,mBAAoB,GACpB,IAAKJ,EACL,GAAGK,EACH,GAAIC,EAAS,CAAE,OAAAA,CAAO,EAAI,CAAC,CAC7B,CACF,CACF,CAEA,MAAMC,EAAe,IAAI,IAKlB,SAASjB,EACdkB,EACAP,EAC2B,CAC3B,MAAMQ,EAAW,MAAM,QAAQD,CAAI,EAAIA,EAAO,CAACA,CAAI,EAC7CE,EAAM,KAAK,UAAU,CAAE,SAAAD,EAAU,QAAAR,CAAQ,CAAC,EAChD,IAAIU,EAAUJ,EAAa,IAAIG,CAAG,EAClC,GAAIC,EACF,OAAOA,EAIT,MAAMC,EAAmBH,EAAS,OAAOI,GAAK,CAACA,EAAE,WAAW,GAAG,CAAC,EAC1DC,EAAmBL,EACtB,OAAOI,GAAKA,EAAE,WAAW,GAAG,CAAC,EAC7B,IAAIA,GAAKA,EAAE,MAAM,CAAC,CAAC,EAEhBE,EAAYnB,EAAa,EAGzBoB,EAAe,CACnB,IAAK,GACL,OAAQ,GACR,GAAGf,EACH,GAAIa,EAAiB,OAAS,EAAI,CAAE,OAAQA,CAAiB,EAAI,CAAC,CACpE,EAEA,OAAAH,EAAUI,EACRH,EAAiB,OAAS,EAAIA,EAAmBH,EACjDO,CACF,EAEAT,EAAa,IAAIG,EAAKC,CAAO,EACtBA,CACT",
|
|
6
6
|
"names": ["globs_exports", "__export", "defaultIgnore", "getGlobMatcher", "globStreamLicenses", "__toCommonJS", "import_objects", "ObjectFreeze", "_picomatch", "getPicomatch", "_fastGlob", "getFastGlob", "globExport", "dirname", "options", "ignoreOpt", "ignoreOriginals", "recursive", "globOptions", "ignore", "matcherCache", "glob", "patterns", "key", "matcher", "positivePatterns", "p", "negativePatterns", "picomatch", "matchOptions"]
|
|
7
7
|
}
|
package/dist/ipc.d.ts
CHANGED
|
@@ -191,7 +191,7 @@ export declare function readIpcStub(stubPath: string): Promise<unknown>;
|
|
|
191
191
|
* periodically or on application startup.
|
|
192
192
|
*
|
|
193
193
|
* ## Cleanup Rules:
|
|
194
|
-
* - Files older than 5 minutes are removed
|
|
194
|
+
* - Files older than 5 minutes are removed (checked via both filesystem mtime and JSON timestamp)
|
|
195
195
|
* - Only stub files (stub-*.json) are processed
|
|
196
196
|
* - Errors are silently ignored (best-effort cleanup)
|
|
197
197
|
*
|
package/dist/ipc.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* Socket Lib - Built with esbuild */
|
|
2
|
-
var
|
|
2
|
+
var P=Object.create;var m=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,A=Object.prototype.hasOwnProperty;var J=(t,e)=>{for(var n in e)m(t,n,{get:e[n],enumerable:!0})},y=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of B(e))!A.call(t,s)&&s!==n&&m(t,s,{get:()=>e[s],enumerable:!(o=N(e,s))||o.enumerable});return t};var k=(t,e,n)=>(n=t!=null?P(O(t)):{},y(e||!t||!t.__esModule?m(n,"default",{value:t,enumerable:!0}):n,t)),$=t=>y(m({},"__esModule",{value:!0}),t);var L={};J(L,{IpcHandshakeSchema:()=>E,cleanupIpcStubs:()=>z,createIpcChannelId:()=>F,createIpcMessage:()=>G,getIpcStubPath:()=>x,hasIpcChannel:()=>K,onIpc:()=>S,parseIpcMessage:()=>v,readIpcStub:()=>W,sendIpc:()=>_,waitForIpc:()=>q,writeIpcStub:()=>H});module.exports=$(L);var l=k(require("node:crypto")),c=require("node:fs"),p=k(require("node:path")),g=require("./fs"),h=require("./paths"),i=require("./zod");const w=i.z.object({id:i.z.string().min(1),timestamp:i.z.number().positive(),type:i.z.string().min(1),data:i.z.unknown()}),E=w.extend({type:i.z.literal("handshake"),data:i.z.object({version:i.z.string(),pid:i.z.number().int().positive(),apiToken:i.z.string().optional(),appName:i.z.string()})}),I=i.z.object({pid:i.z.number().int().positive(),timestamp:i.z.number().positive(),data:i.z.unknown()});function F(t="socket"){return`${t}-${process.pid}-${l.default.randomBytes(8).toString("hex")}`}function x(t){const e=(0,h.getOsTmpDir)(),n=p.default.join(e,".socket-ipc",t);return p.default.join(n,`stub-${process.pid}.json`)}async function C(t){const e=p.default.dirname(t);await c.promises.mkdir(e,{recursive:!0})}async function H(t,e){const n=x(t);await C(n);const o={data:e,pid:process.pid,timestamp:Date.now()},s=I.parse(o);return await c.promises.writeFile(n,JSON.stringify(s,null,2),"utf8"),n}async function W(t){try{const e=await c.promises.readFile(t,"utf8"),n=JSON.parse(e),o=I.parse(n),s=Date.now()-o.timestamp,a=300*1e3;if(s>a){try{(0,g.safeDeleteSync)(t,{force:!0})}catch{}return null}return o.data}catch{return null}}async function z(t){const e=(0,h.getOsTmpDir)(),n=p.default.join(e,".socket-ipc",t);try{const o=await c.promises.readdir(n),s=Date.now(),a=300*1e3;await Promise.all(o.map(async r=>{if(r.startsWith("stub-")&&r.endsWith(".json")){const u=p.default.join(n,r);try{const b=await c.promises.stat(u);let f=s-b.mtimeMs>a;try{const M=await c.promises.readFile(u,"utf8"),T=JSON.parse(M),D=I.parse(T),j=s-D.timestamp;f=f||j>a}catch{}f&&(0,g.safeDeleteSync)(u,{force:!0})}catch{}}}))}catch{}}function _(t,e){if(t&&typeof t=="object"&&"send"in t&&typeof t.send=="function")try{const n=w.parse(e);return t.send(n)}catch{return!1}return!1}function S(t){const e=n=>{const o=v(n);o&&t(o)};return process.on("message",e),()=>{process.off("message",e)}}function q(t,e={}){const{timeout:n=3e4}=e;return new Promise((o,s)=>{let a=null,r=null;const u=()=>{a&&a(),s(new Error(`IPC timeout waiting for message type: ${t}`))};a=S(d=>{d.type===t&&(r&&clearTimeout(r),a&&a(),o(d.data))}),n>0&&(r=setTimeout(u,n))})}function G(t,e){return{id:l.default.randomBytes(16).toString("hex"),timestamp:Date.now(),type:t,data:e}}function K(t){return!!(t&&typeof t=="object"&&"send"in t&&typeof t.send=="function"&&"channel"in t&&t.channel!==void 0)}function v(t){try{return w.parse(t)}catch{return null}}0&&(module.exports={IpcHandshakeSchema,cleanupIpcStubs,createIpcChannelId,createIpcMessage,getIpcStubPath,hasIpcChannel,onIpc,parseIpcMessage,readIpcStub,sendIpc,waitForIpc,writeIpcStub});
|
|
3
3
|
//# sourceMappingURL=ipc.js.map
|
package/dist/ipc.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/ipc.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * IPC (Inter-Process Communication) Module\n * ==========================================\n *\n * This module provides secure inter-process communication utilities for Socket CLI\n * and related tools. It replaces environment variable passing with more secure and\n * scalable alternatives.\n *\n * ## Key Features:\n * - File-based stub communication for initial data handoff\n * - Node.js IPC channel support for real-time bidirectional messaging\n * - Automatic cleanup of temporary files\n * - Type-safe message validation with Zod schemas\n * - Timeout handling for reliability\n *\n * ## Use Cases:\n * 1. Passing API tokens between processes without exposing them in env vars\n * 2. Transferring large configuration objects that exceed env var size limits\n * 3. Bidirectional communication between parent and child processes\n * 4. Secure handshake protocols between Socket CLI components\n *\n * ## Security Considerations:\n * - Stub files are created with restricted permissions in OS temp directory\n * - Messages include timestamps for freshness validation\n * - Automatic cleanup prevents sensitive data persistence\n * - Unique IDs prevent message replay attacks\n *\n * @module ipc\n */\n\nimport crypto from 'node:crypto'\nimport { promises as fs } from 'node:fs'\nimport os from 'node:os'\nimport path from 'node:path'\n\nimport { z } from './zod'\n\n// Define BufferEncoding type for TypeScript compatibility.\ntype BufferEncoding = globalThis.BufferEncoding\n\n/**\n * Zod Schemas for Runtime Validation\n * ====================================\n * These schemas provide runtime type safety for IPC messages,\n * ensuring data integrity across process boundaries.\n */\n\n/**\n * Base IPC message schema - validates the core message structure.\n * All IPC messages must conform to this schema.\n */\nconst IpcMessageSchema = z.object({\n /** Unique identifier for message tracking and response correlation. */\n id: z.string().min(1),\n /** Unix timestamp for freshness validation and replay prevention. */\n timestamp: z.number().positive(),\n /** Message type identifier for routing and handling. */\n type: z.string().min(1),\n /** Payload data - can be any JSON-serializable value. */\n data: z.unknown(),\n})\n\n/**\n * IPC handshake schema - used for initial connection establishment.\n * The handshake includes version info and authentication tokens.\n * @internal Exported for testing purposes.\n */\nexport const IpcHandshakeSchema = IpcMessageSchema.extend({\n type: z.literal('handshake'),\n data: z.object({\n /** Protocol version for compatibility checking. */\n version: z.string(),\n /** Process ID for identification. */\n pid: z.number().int().positive(),\n /** Optional API token for authentication. */\n apiToken: z.string().optional(),\n /** Application name for multi-app support. */\n appName: z.string(),\n }),\n})\n\n/**\n * IPC stub file schema - validates the structure of stub files.\n * Stub files are used for passing data between processes via filesystem.\n */\nconst IpcStubSchema = z.object({\n /** Process ID that created the stub. */\n pid: z.number().int().positive(),\n /** Creation timestamp for age validation. */\n timestamp: z.number().positive(),\n /** The actual data payload. */\n data: z.unknown(),\n})\n\n/**\n * TypeScript interfaces for IPC communication.\n * These types ensure type consistency across the IPC module.\n */\n\n/**\n * Base IPC message interface.\n * All IPC messages must conform to this structure.\n */\nexport interface IpcMessage<T = unknown> {\n /** Unique identifier for message tracking and response correlation. */\n id: string\n /** Unix timestamp for freshness validation and replay prevention. */\n timestamp: number\n /** Message type identifier for routing and handling. */\n type: string\n /** Payload data - can be any JSON-serializable value. */\n data: T\n}\n\n/**\n * IPC handshake message interface.\n * Used for initial connection establishment.\n */\nexport interface IpcHandshake\n extends IpcMessage<{\n /** Protocol version for compatibility checking. */\n version: string\n /** Process ID for identification. */\n pid: number\n /** Optional API token for authentication. */\n apiToken?: string\n /** Application name for multi-app support. */\n appName: string\n }> {\n type: 'handshake'\n}\n\n/**\n * IPC stub file interface.\n * Represents the structure of stub files used for filesystem-based IPC.\n */\nexport interface IpcStub {\n /** Process ID that created the stub. */\n pid: number\n /** Creation timestamp for age validation. */\n timestamp: number\n /** The actual data payload. */\n data: unknown\n}\n\n/**\n * Options for IPC communication\n */\nexport interface IpcOptions {\n /** Timeout in milliseconds for async operations. */\n timeout?: number\n /** Text encoding for message serialization. */\n encoding?: BufferEncoding\n}\n\n/**\n * Create a unique IPC channel identifier for message correlation.\n *\n * Generates a unique identifier that combines:\n * - A prefix for namespacing (defaults to 'socket')\n * - The current process ID for process identification\n * - A random hex string for uniqueness\n *\n * @param prefix - Optional prefix to namespace the channel ID\n * @returns A unique channel identifier string\n *\n * @example\n * ```typescript\n * const channelId = createIpcChannelId('socket-cli')\n * // Returns: 'socket-cli-12345-a1b2c3d4e5f6g7h8'\n * ```\n */\nexport function createIpcChannelId(prefix = 'socket'): string {\n return `${prefix}-${process.pid}-${crypto.randomBytes(8).toString('hex')}`\n}\n\n/**\n * Get the IPC stub path for a given application.\n *\n * This function generates a unique file path for IPC stub files that are used\n * to pass data between processes. The stub files are stored in a hidden directory\n * within the system's temporary folder.\n *\n * ## Path Structure:\n * - Base: System temp directory (e.g., /tmp on Unix, %TEMP% on Windows)\n * - Directory: `.socket-ipc/{appName}/`\n * - Filename: `stub-{pid}.json`\n *\n * ## Security Features:\n * - Files are isolated per application via appName parameter\n * - Process ID in filename prevents collisions between concurrent processes\n * - Temporary directory location ensures automatic cleanup on system restart\n *\n * @param appName - The application identifier (e.g., 'socket-cli', 'socket-dlx')\n * @returns Full path to the IPC stub file\n *\n * @example\n * ```typescript\n * const stubPath = getIpcStubPath('socket-cli')\n * // Returns: '/tmp/.socket-ipc/socket-cli/stub-12345.json' (Unix)\n * // Returns: 'C:\\\\Users\\\\Name\\\\AppData\\\\Local\\\\Temp\\\\.socket-ipc\\\\socket-cli\\\\stub-12345.json' (Windows)\n * ```\n *\n * @used Currently used by socket-cli for self-update and inter-process communication\n */\nexport function getIpcStubPath(appName: string): string {\n // Get the system's temporary directory - this is platform-specific.\n const tempDir = os.tmpdir()\n\n // Create a hidden directory structure for Socket IPC files.\n // The dot prefix makes it hidden on Unix-like systems.\n const stubDir = path.join(tempDir, '.socket-ipc', appName)\n\n // Generate filename with process ID to ensure uniqueness.\n // The PID prevents conflicts when multiple processes run simultaneously.\n return path.join(stubDir, `stub-${process.pid}.json`)\n}\n\n/**\n * Ensure IPC directory exists for stub file creation.\n *\n * This helper function creates the directory structure needed for IPC stub files.\n * It's called before writing stub files to ensure the parent directories exist.\n *\n * @param filePath - Full path to the file that needs its directory created\n * @returns Promise that resolves when directory is created\n *\n * @internal Helper function used by writeIpcStub\n */\nasync function ensureIpcDirectory(filePath: string): Promise<void> {\n const dir = path.dirname(filePath)\n // Create directory recursively if it doesn't exist.\n await fs.mkdir(dir, { recursive: true })\n}\n\n/**\n * Write IPC data to a stub file for inter-process data transfer.\n *\n * This function creates a stub file containing data that needs to be passed\n * between processes. The stub file includes metadata like process ID and\n * timestamp for validation.\n *\n * ## File Structure:\n * ```json\n * {\n * \"pid\": 12345,\n * \"timestamp\": 1699564234567,\n * \"data\": { ... }\n * }\n * ```\n *\n * ## Use Cases:\n * - Passing API tokens to child processes\n * - Transferring configuration between Socket CLI components\n * - Sharing large data that exceeds environment variable limits\n *\n * @param appName - The application identifier\n * @param data - The data to write to the stub file\n * @returns Promise resolving to the stub file path\n *\n * @example\n * ```typescript\n * const stubPath = await writeIpcStub('socket-cli', {\n * apiToken: 'secret-token',\n * config: { ... }\n * })\n * // Pass stubPath to child process for reading\n * ```\n */\nexport async function writeIpcStub(\n appName: string,\n data: unknown,\n): Promise<string> {\n const stubPath = getIpcStubPath(appName)\n await ensureIpcDirectory(stubPath)\n\n // Create stub data with validation metadata.\n const ipcData: IpcStub = {\n data,\n pid: process.pid,\n timestamp: Date.now(),\n }\n\n // Validate data structure with Zod schema.\n const validated = IpcStubSchema.parse(ipcData)\n\n // Write with pretty printing for debugging.\n await fs.writeFile(stubPath, JSON.stringify(validated, null, 2), 'utf8')\n return stubPath\n}\n\n/**\n * Read IPC data from a stub file with automatic cleanup.\n *\n * This function reads data from an IPC stub file and validates its freshness.\n * Stale files (older than 5 minutes) are automatically cleaned up to prevent\n * accumulation of temporary files.\n *\n * ## Validation Steps:\n * 1. Read and parse JSON file\n * 2. Validate structure with Zod schema\n * 3. Check timestamp freshness\n * 4. Clean up if stale\n * 5. Return data if valid\n *\n * @param stubPath - Path to the stub file to read\n * @returns Promise resolving to the data or null if invalid/stale\n *\n * @example\n * ```typescript\n * const data = await readIpcStub('/tmp/.socket-ipc/socket-cli/stub-12345.json')\n * if (data) {\n * console.log('Received:', data)\n * }\n * ```\n *\n * @unused Reserved for future implementation\n */\nexport async function readIpcStub(stubPath: string): Promise<unknown> {\n try {\n const content = await fs.readFile(stubPath, 'utf8')\n const parsed = JSON.parse(content)\n // Validate structure with Zod schema.\n const validated = IpcStubSchema.parse(parsed)\n // Check age for freshness validation.\n const ageMs = Date.now() - validated.timestamp\n // 5 minutes.\n const maxAgeMs = 5 * 60 * 1000\n if (ageMs > maxAgeMs) {\n // Clean up stale file.\n await fs.unlink(stubPath).catch(() => {})\n return null\n }\n return validated.data\n } catch {\n // Return null for any errors (file not found, invalid JSON, validation failure).\n return null\n }\n}\n\n/**\n * Clean up IPC stub files for an application.\n *\n * This maintenance function removes stale IPC stub files to prevent\n * accumulation in the temporary directory. It's designed to be called\n * periodically or on application startup.\n *\n * ## Cleanup Rules:\n * - Files older than 5 minutes are removed\n * - Only stub files (stub-*.json) are processed\n * - Errors are silently ignored (best-effort cleanup)\n *\n * @param appName - The application identifier\n * @returns Promise that resolves when cleanup is complete\n *\n * @example\n * ```typescript\n * // Clean up on application startup\n * await cleanupIpcStubs('socket-cli')\n * ```\n *\n * @unused Reserved for future implementation\n */\nexport async function cleanupIpcStubs(appName: string): Promise<void> {\n const tempDir = os.tmpdir()\n const stubDir = path.join(tempDir, '.socket-ipc', appName)\n try {\n const files = await fs.readdir(stubDir)\n const now = Date.now()\n // 5 minutes.\n const maxAgeMs = 5 * 60 * 1000\n // Process each file in parallel for efficiency.\n await Promise.all(\n files.map(async file => {\n if (file.startsWith('stub-') && file.endsWith('.json')) {\n const filePath = path.join(stubDir, file)\n try {\n const stats = await fs.stat(filePath)\n const ageMs = now - stats.mtimeMs\n if (ageMs > maxAgeMs) {\n await fs.unlink(filePath)\n }\n } catch {\n // Ignore errors for individual files.\n }\n }\n }),\n )\n } catch {\n // Directory might not exist, that's ok.\n }\n}\n\n/**\n * Send data through Node.js IPC channel.\n *\n * This function sends structured messages through the Node.js IPC channel\n * when available. The IPC channel must be established with stdio: ['pipe', 'pipe', 'pipe', 'ipc'].\n *\n * ## Requirements:\n * - Process must have been spawned with IPC channel enabled\n * - Message must be serializable to JSON\n * - Process.send() must be available\n *\n * @param process - The process object with IPC channel\n * @param message - The IPC message to send\n * @returns true if message was sent, false otherwise\n *\n * @example\n * ```typescript\n * const message = createIpcMessage('handshake', { version: '1.0.0' })\n * const sent = sendIpc(childProcess, message)\n * ```\n *\n * @unused Reserved for bidirectional communication implementation\n */\nexport function sendIpc(\n process: NodeJS.Process | unknown,\n message: IpcMessage,\n): boolean {\n if (\n process &&\n typeof process === 'object' &&\n 'send' in process &&\n typeof process.send === 'function'\n ) {\n try {\n // Validate message structure before sending.\n const validated = IpcMessageSchema.parse(message)\n return process.send(validated)\n } catch {\n return false\n }\n }\n return false\n}\n\n/**\n * Receive data through Node.js IPC channel.\n *\n * Sets up a listener for IPC messages with automatic validation and parsing.\n * Returns a cleanup function to remove the listener when no longer needed.\n *\n * ## Message Flow:\n * 1. Receive raw message from IPC channel\n * 2. Validate with parseIpcMessage\n * 3. Call handler if valid\n * 4. Ignore invalid messages\n *\n * @param handler - Function to call with valid IPC messages\n * @returns Cleanup function to remove the listener\n *\n * @example\n * ```typescript\n * const cleanup = onIpc((message) => {\n * console.log('Received:', message.type, message.data)\n * })\n * // Later...\n * cleanup() // Remove listener\n * ```\n *\n * @unused Reserved for bidirectional communication\n */\nexport function onIpc(handler: (message: IpcMessage) => void): () => void {\n const listener = (message: unknown) => {\n const parsed = parseIpcMessage(message)\n if (parsed) {\n handler(parsed)\n }\n }\n process.on('message', listener)\n // Return cleanup function for proper resource management.\n return () => {\n process.off('message', listener)\n }\n}\n\n/**\n * Create a promise that resolves when a specific IPC message is received.\n *\n * This utility function provides async/await support for IPC communication,\n * allowing you to wait for specific message types with timeout support.\n *\n * ## Features:\n * - Automatic timeout handling\n * - Type-safe message data\n * - Resource cleanup on completion\n * - Promise-based API\n *\n * @param messageType - The message type to wait for\n * @param options - Options including timeout configuration\n * @returns Promise resolving to the message data\n *\n * @example\n * ```typescript\n * try {\n * const response = await waitForIpc<ConfigData>('config-response', {\n * timeout: 5000 // 5 seconds\n * })\n * console.log('Config received:', response)\n * } catch (error) {\n * console.error('Timeout waiting for config')\n * }\n * ```\n *\n * @unused Reserved for request-response pattern implementation\n */\nexport function waitForIpc<T = unknown>(\n messageType: string,\n options: IpcOptions = {},\n): Promise<T> {\n const { timeout = 30_000 } = options\n return new Promise((resolve, reject) => {\n let cleanup: (() => void) | null = null\n let timeoutId: NodeJS.Timeout | null = null\n const handleTimeout = () => {\n if (cleanup) {\n cleanup()\n }\n reject(new Error(`IPC timeout waiting for message type: ${messageType}`))\n }\n const handleMessage = (message: IpcMessage) => {\n if (message.type === messageType) {\n if (timeoutId) {\n clearTimeout(timeoutId)\n }\n if (cleanup) {\n cleanup()\n }\n resolve(message.data as T)\n }\n }\n cleanup = onIpc(handleMessage)\n if (timeout > 0) {\n timeoutId = setTimeout(handleTimeout, timeout)\n }\n })\n}\n\n/**\n * Create an IPC message with proper structure and metadata.\n *\n * This factory function creates properly structured IPC messages with:\n * - Unique ID for tracking\n * - Timestamp for freshness\n * - Type for routing\n * - Data payload\n *\n * @param type - The message type identifier\n * @param data - The message payload\n * @returns A properly structured IPC message\n *\n * @example\n * ```typescript\n * const handshake = createIpcMessage('handshake', {\n * version: '1.0.0',\n * pid: process.pid,\n * appName: 'socket-cli'\n * })\n * ```\n *\n * @unused Reserved for future message creation needs\n */\nexport function createIpcMessage<T = unknown>(\n type: string,\n data: T,\n): IpcMessage<T> {\n return {\n id: crypto.randomBytes(16).toString('hex'),\n timestamp: Date.now(),\n type,\n data,\n }\n}\n\n/**\n * Check if process has IPC channel available.\n *\n * This utility checks whether a process object has the necessary\n * properties for IPC communication. Used to determine if IPC\n * messaging is possible before attempting to send.\n *\n * @param process - The process object to check\n * @returns true if IPC is available, false otherwise\n *\n * @example\n * ```typescript\n * if (hasIpcChannel(childProcess)) {\n * sendIpc(childProcess, message)\n * } else {\n * // Fall back to alternative communication method\n * }\n * ```\n *\n * @unused Reserved for IPC availability detection\n */\nexport function hasIpcChannel(process: unknown): boolean {\n return Boolean(\n process &&\n typeof process === 'object' &&\n 'send' in process &&\n typeof process.send === 'function' &&\n 'channel' in process &&\n process.channel !== undefined,\n )\n}\n\n/**\n * Safely parse and validate IPC messages.\n *\n * This function performs runtime validation of incoming messages\n * to ensure they conform to the IPC message structure. It uses\n * Zod schemas for robust validation.\n *\n * ## Validation Steps:\n * 1. Check if message is an object\n * 2. Validate required fields exist\n * 3. Validate field types\n * 4. Return typed message or null\n *\n * @param message - The raw message to parse\n * @returns Parsed IPC message or null if invalid\n *\n * @example\n * ```typescript\n * const parsed = parseIpcMessage(rawMessage)\n * if (parsed) {\n * handleMessage(parsed)\n * }\n * ```\n *\n * @unused Reserved for message validation needs\n */\nexport function parseIpcMessage(message: unknown): IpcMessage | null {\n try {\n // Use Zod schema for comprehensive validation.\n const validated = IpcMessageSchema.parse(message)\n return validated as IpcMessage\n } catch {\n // Return null for any validation failure.\n return null\n }\n}\n"],
|
|
5
|
-
"mappings": ";6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,EAAA,oBAAAC,EAAA,uBAAAC,EAAA,qBAAAC,EAAA,mBAAAC,EAAA,kBAAAC,EAAA,UAAAC,EAAA,oBAAAC,EAAA,gBAAAC,EAAA,YAAAC,EAAA,eAAAC,EAAA,iBAAAC,IAAA,eAAAC,EAAAd,GA8BA,IAAAe,EAAmB,0BACnBC,EAA+B,mBAC/BC,
|
|
6
|
-
"names": ["ipc_exports", "__export", "IpcHandshakeSchema", "cleanupIpcStubs", "createIpcChannelId", "createIpcMessage", "getIpcStubPath", "hasIpcChannel", "onIpc", "parseIpcMessage", "readIpcStub", "sendIpc", "waitForIpc", "writeIpcStub", "__toCommonJS", "import_node_crypto", "import_node_fs", "
|
|
4
|
+
"sourcesContent": ["/**\n * IPC (Inter-Process Communication) Module\n * ==========================================\n *\n * This module provides secure inter-process communication utilities for Socket CLI\n * and related tools. It replaces environment variable passing with more secure and\n * scalable alternatives.\n *\n * ## Key Features:\n * - File-based stub communication for initial data handoff\n * - Node.js IPC channel support for real-time bidirectional messaging\n * - Automatic cleanup of temporary files\n * - Type-safe message validation with Zod schemas\n * - Timeout handling for reliability\n *\n * ## Use Cases:\n * 1. Passing API tokens between processes without exposing them in env vars\n * 2. Transferring large configuration objects that exceed env var size limits\n * 3. Bidirectional communication between parent and child processes\n * 4. Secure handshake protocols between Socket CLI components\n *\n * ## Security Considerations:\n * - Stub files are created with restricted permissions in OS temp directory\n * - Messages include timestamps for freshness validation\n * - Automatic cleanup prevents sensitive data persistence\n * - Unique IDs prevent message replay attacks\n *\n * @module ipc\n */\n\nimport crypto from 'node:crypto'\nimport { promises as fs } from 'node:fs'\nimport path from 'node:path'\n\nimport { safeDeleteSync } from './fs'\nimport { getOsTmpDir } from './paths'\nimport { z } from './zod'\n\n// Define BufferEncoding type for TypeScript compatibility.\ntype BufferEncoding = globalThis.BufferEncoding\n\n/**\n * Zod Schemas for Runtime Validation\n * ====================================\n * These schemas provide runtime type safety for IPC messages,\n * ensuring data integrity across process boundaries.\n */\n\n/**\n * Base IPC message schema - validates the core message structure.\n * All IPC messages must conform to this schema.\n */\nconst IpcMessageSchema = z.object({\n /** Unique identifier for message tracking and response correlation. */\n id: z.string().min(1),\n /** Unix timestamp for freshness validation and replay prevention. */\n timestamp: z.number().positive(),\n /** Message type identifier for routing and handling. */\n type: z.string().min(1),\n /** Payload data - can be any JSON-serializable value. */\n data: z.unknown(),\n})\n\n/**\n * IPC handshake schema - used for initial connection establishment.\n * The handshake includes version info and authentication tokens.\n * @internal Exported for testing purposes.\n */\nexport const IpcHandshakeSchema = IpcMessageSchema.extend({\n type: z.literal('handshake'),\n data: z.object({\n /** Protocol version for compatibility checking. */\n version: z.string(),\n /** Process ID for identification. */\n pid: z.number().int().positive(),\n /** Optional API token for authentication. */\n apiToken: z.string().optional(),\n /** Application name for multi-app support. */\n appName: z.string(),\n }),\n})\n\n/**\n * IPC stub file schema - validates the structure of stub files.\n * Stub files are used for passing data between processes via filesystem.\n */\nconst IpcStubSchema = z.object({\n /** Process ID that created the stub. */\n pid: z.number().int().positive(),\n /** Creation timestamp for age validation. */\n timestamp: z.number().positive(),\n /** The actual data payload. */\n data: z.unknown(),\n})\n\n/**\n * TypeScript interfaces for IPC communication.\n * These types ensure type consistency across the IPC module.\n */\n\n/**\n * Base IPC message interface.\n * All IPC messages must conform to this structure.\n */\nexport interface IpcMessage<T = unknown> {\n /** Unique identifier for message tracking and response correlation. */\n id: string\n /** Unix timestamp for freshness validation and replay prevention. */\n timestamp: number\n /** Message type identifier for routing and handling. */\n type: string\n /** Payload data - can be any JSON-serializable value. */\n data: T\n}\n\n/**\n * IPC handshake message interface.\n * Used for initial connection establishment.\n */\nexport interface IpcHandshake\n extends IpcMessage<{\n /** Protocol version for compatibility checking. */\n version: string\n /** Process ID for identification. */\n pid: number\n /** Optional API token for authentication. */\n apiToken?: string\n /** Application name for multi-app support. */\n appName: string\n }> {\n type: 'handshake'\n}\n\n/**\n * IPC stub file interface.\n * Represents the structure of stub files used for filesystem-based IPC.\n */\nexport interface IpcStub {\n /** Process ID that created the stub. */\n pid: number\n /** Creation timestamp for age validation. */\n timestamp: number\n /** The actual data payload. */\n data: unknown\n}\n\n/**\n * Options for IPC communication\n */\nexport interface IpcOptions {\n /** Timeout in milliseconds for async operations. */\n timeout?: number\n /** Text encoding for message serialization. */\n encoding?: BufferEncoding\n}\n\n/**\n * Create a unique IPC channel identifier for message correlation.\n *\n * Generates a unique identifier that combines:\n * - A prefix for namespacing (defaults to 'socket')\n * - The current process ID for process identification\n * - A random hex string for uniqueness\n *\n * @param prefix - Optional prefix to namespace the channel ID\n * @returns A unique channel identifier string\n *\n * @example\n * ```typescript\n * const channelId = createIpcChannelId('socket-cli')\n * // Returns: 'socket-cli-12345-a1b2c3d4e5f6g7h8'\n * ```\n */\nexport function createIpcChannelId(prefix = 'socket'): string {\n return `${prefix}-${process.pid}-${crypto.randomBytes(8).toString('hex')}`\n}\n\n/**\n * Get the IPC stub path for a given application.\n *\n * This function generates a unique file path for IPC stub files that are used\n * to pass data between processes. The stub files are stored in a hidden directory\n * within the system's temporary folder.\n *\n * ## Path Structure:\n * - Base: System temp directory (e.g., /tmp on Unix, %TEMP% on Windows)\n * - Directory: `.socket-ipc/{appName}/`\n * - Filename: `stub-{pid}.json`\n *\n * ## Security Features:\n * - Files are isolated per application via appName parameter\n * - Process ID in filename prevents collisions between concurrent processes\n * - Temporary directory location ensures automatic cleanup on system restart\n *\n * @param appName - The application identifier (e.g., 'socket-cli', 'socket-dlx')\n * @returns Full path to the IPC stub file\n *\n * @example\n * ```typescript\n * const stubPath = getIpcStubPath('socket-cli')\n * // Returns: '/tmp/.socket-ipc/socket-cli/stub-12345.json' (Unix)\n * // Returns: 'C:\\\\Users\\\\Name\\\\AppData\\\\Local\\\\Temp\\\\.socket-ipc\\\\socket-cli\\\\stub-12345.json' (Windows)\n * ```\n *\n * @used Currently used by socket-cli for self-update and inter-process communication\n */\nexport function getIpcStubPath(appName: string): string {\n // Get the system's temporary directory - this is platform-specific.\n const tempDir = getOsTmpDir()\n\n // Create a hidden directory structure for Socket IPC files.\n // The dot prefix makes it hidden on Unix-like systems.\n const stubDir = path.join(tempDir, '.socket-ipc', appName)\n\n // Generate filename with process ID to ensure uniqueness.\n // The PID prevents conflicts when multiple processes run simultaneously.\n return path.join(stubDir, `stub-${process.pid}.json`)\n}\n\n/**\n * Ensure IPC directory exists for stub file creation.\n *\n * This helper function creates the directory structure needed for IPC stub files.\n * It's called before writing stub files to ensure the parent directories exist.\n *\n * @param filePath - Full path to the file that needs its directory created\n * @returns Promise that resolves when directory is created\n *\n * @internal Helper function used by writeIpcStub\n */\nasync function ensureIpcDirectory(filePath: string): Promise<void> {\n const dir = path.dirname(filePath)\n // Create directory recursively if it doesn't exist.\n await fs.mkdir(dir, { recursive: true })\n}\n\n/**\n * Write IPC data to a stub file for inter-process data transfer.\n *\n * This function creates a stub file containing data that needs to be passed\n * between processes. The stub file includes metadata like process ID and\n * timestamp for validation.\n *\n * ## File Structure:\n * ```json\n * {\n * \"pid\": 12345,\n * \"timestamp\": 1699564234567,\n * \"data\": { ... }\n * }\n * ```\n *\n * ## Use Cases:\n * - Passing API tokens to child processes\n * - Transferring configuration between Socket CLI components\n * - Sharing large data that exceeds environment variable limits\n *\n * @param appName - The application identifier\n * @param data - The data to write to the stub file\n * @returns Promise resolving to the stub file path\n *\n * @example\n * ```typescript\n * const stubPath = await writeIpcStub('socket-cli', {\n * apiToken: 'secret-token',\n * config: { ... }\n * })\n * // Pass stubPath to child process for reading\n * ```\n */\nexport async function writeIpcStub(\n appName: string,\n data: unknown,\n): Promise<string> {\n const stubPath = getIpcStubPath(appName)\n await ensureIpcDirectory(stubPath)\n\n // Create stub data with validation metadata.\n const ipcData: IpcStub = {\n data,\n pid: process.pid,\n timestamp: Date.now(),\n }\n\n // Validate data structure with Zod schema.\n const validated = IpcStubSchema.parse(ipcData)\n\n // Write with pretty printing for debugging.\n await fs.writeFile(stubPath, JSON.stringify(validated, null, 2), 'utf8')\n return stubPath\n}\n\n/**\n * Read IPC data from a stub file with automatic cleanup.\n *\n * This function reads data from an IPC stub file and validates its freshness.\n * Stale files (older than 5 minutes) are automatically cleaned up to prevent\n * accumulation of temporary files.\n *\n * ## Validation Steps:\n * 1. Read and parse JSON file\n * 2. Validate structure with Zod schema\n * 3. Check timestamp freshness\n * 4. Clean up if stale\n * 5. Return data if valid\n *\n * @param stubPath - Path to the stub file to read\n * @returns Promise resolving to the data or null if invalid/stale\n *\n * @example\n * ```typescript\n * const data = await readIpcStub('/tmp/.socket-ipc/socket-cli/stub-12345.json')\n * if (data) {\n * console.log('Received:', data)\n * }\n * ```\n *\n * @unused Reserved for future implementation\n */\nexport async function readIpcStub(stubPath: string): Promise<unknown> {\n try {\n const content = await fs.readFile(stubPath, 'utf8')\n const parsed = JSON.parse(content)\n // Validate structure with Zod schema.\n const validated = IpcStubSchema.parse(parsed)\n // Check age for freshness validation.\n const ageMs = Date.now() - validated.timestamp\n // 5 minutes.\n const maxAgeMs = 5 * 60 * 1000\n if (ageMs > maxAgeMs) {\n // Clean up stale file. IPC stubs are always in tmpdir, so use force: true.\n try {\n safeDeleteSync(stubPath, { force: true })\n } catch {\n // Ignore deletion errors\n }\n return null\n }\n return validated.data\n } catch {\n // Return null for any errors (file not found, invalid JSON, validation failure).\n return null\n }\n}\n\n/**\n * Clean up IPC stub files for an application.\n *\n * This maintenance function removes stale IPC stub files to prevent\n * accumulation in the temporary directory. It's designed to be called\n * periodically or on application startup.\n *\n * ## Cleanup Rules:\n * - Files older than 5 minutes are removed (checked via both filesystem mtime and JSON timestamp)\n * - Only stub files (stub-*.json) are processed\n * - Errors are silently ignored (best-effort cleanup)\n *\n * @param appName - The application identifier\n * @returns Promise that resolves when cleanup is complete\n *\n * @example\n * ```typescript\n * // Clean up on application startup\n * await cleanupIpcStubs('socket-cli')\n * ```\n *\n * @unused Reserved for future implementation\n */\nexport async function cleanupIpcStubs(appName: string): Promise<void> {\n const tempDir = getOsTmpDir()\n const stubDir = path.join(tempDir, '.socket-ipc', appName)\n try {\n const files = await fs.readdir(stubDir)\n const now = Date.now()\n // 5 minutes.\n const maxAgeMs = 5 * 60 * 1000\n // Process each file in parallel for efficiency.\n await Promise.all(\n files.map(async file => {\n if (file.startsWith('stub-') && file.endsWith('.json')) {\n const filePath = path.join(stubDir, file)\n try {\n // Check both filesystem mtime and JSON timestamp for more reliable detection\n const stats = await fs.stat(filePath)\n const mtimeAge = now - stats.mtimeMs\n let isStale = mtimeAge > maxAgeMs\n\n // Always check the timestamp inside the JSON file for accuracy\n // This is more reliable than filesystem mtime in some environments\n try {\n const content = await fs.readFile(filePath, 'utf8')\n const parsed = JSON.parse(content)\n const validated = IpcStubSchema.parse(parsed)\n const contentAge = now - validated.timestamp\n // File is stale if EITHER check indicates staleness\n isStale = isStale || contentAge > maxAgeMs\n } catch {\n // If we can't read/parse the file, rely on mtime check\n }\n\n if (isStale) {\n // IPC stubs are always in tmpdir, so we can use force: true to skip path checks\n safeDeleteSync(filePath, { force: true })\n }\n } catch {\n // Ignore errors for individual files.\n }\n }\n }),\n )\n } catch {\n // Directory might not exist, that's ok.\n }\n}\n\n/**\n * Send data through Node.js IPC channel.\n *\n * This function sends structured messages through the Node.js IPC channel\n * when available. The IPC channel must be established with stdio: ['pipe', 'pipe', 'pipe', 'ipc'].\n *\n * ## Requirements:\n * - Process must have been spawned with IPC channel enabled\n * - Message must be serializable to JSON\n * - Process.send() must be available\n *\n * @param process - The process object with IPC channel\n * @param message - The IPC message to send\n * @returns true if message was sent, false otherwise\n *\n * @example\n * ```typescript\n * const message = createIpcMessage('handshake', { version: '1.0.0' })\n * const sent = sendIpc(childProcess, message)\n * ```\n *\n * @unused Reserved for bidirectional communication implementation\n */\nexport function sendIpc(\n process: NodeJS.Process | unknown,\n message: IpcMessage,\n): boolean {\n if (\n process &&\n typeof process === 'object' &&\n 'send' in process &&\n typeof process.send === 'function'\n ) {\n try {\n // Validate message structure before sending.\n const validated = IpcMessageSchema.parse(message)\n return process.send(validated)\n } catch {\n return false\n }\n }\n return false\n}\n\n/**\n * Receive data through Node.js IPC channel.\n *\n * Sets up a listener for IPC messages with automatic validation and parsing.\n * Returns a cleanup function to remove the listener when no longer needed.\n *\n * ## Message Flow:\n * 1. Receive raw message from IPC channel\n * 2. Validate with parseIpcMessage\n * 3. Call handler if valid\n * 4. Ignore invalid messages\n *\n * @param handler - Function to call with valid IPC messages\n * @returns Cleanup function to remove the listener\n *\n * @example\n * ```typescript\n * const cleanup = onIpc((message) => {\n * console.log('Received:', message.type, message.data)\n * })\n * // Later...\n * cleanup() // Remove listener\n * ```\n *\n * @unused Reserved for bidirectional communication\n */\nexport function onIpc(handler: (message: IpcMessage) => void): () => void {\n const listener = (message: unknown) => {\n const parsed = parseIpcMessage(message)\n if (parsed) {\n handler(parsed)\n }\n }\n process.on('message', listener)\n // Return cleanup function for proper resource management.\n return () => {\n process.off('message', listener)\n }\n}\n\n/**\n * Create a promise that resolves when a specific IPC message is received.\n *\n * This utility function provides async/await support for IPC communication,\n * allowing you to wait for specific message types with timeout support.\n *\n * ## Features:\n * - Automatic timeout handling\n * - Type-safe message data\n * - Resource cleanup on completion\n * - Promise-based API\n *\n * @param messageType - The message type to wait for\n * @param options - Options including timeout configuration\n * @returns Promise resolving to the message data\n *\n * @example\n * ```typescript\n * try {\n * const response = await waitForIpc<ConfigData>('config-response', {\n * timeout: 5000 // 5 seconds\n * })\n * console.log('Config received:', response)\n * } catch (error) {\n * console.error('Timeout waiting for config')\n * }\n * ```\n *\n * @unused Reserved for request-response pattern implementation\n */\nexport function waitForIpc<T = unknown>(\n messageType: string,\n options: IpcOptions = {},\n): Promise<T> {\n const { timeout = 30_000 } = options\n return new Promise((resolve, reject) => {\n let cleanup: (() => void) | null = null\n let timeoutId: NodeJS.Timeout | null = null\n const handleTimeout = () => {\n if (cleanup) {\n cleanup()\n }\n reject(new Error(`IPC timeout waiting for message type: ${messageType}`))\n }\n const handleMessage = (message: IpcMessage) => {\n if (message.type === messageType) {\n if (timeoutId) {\n clearTimeout(timeoutId)\n }\n if (cleanup) {\n cleanup()\n }\n resolve(message.data as T)\n }\n }\n cleanup = onIpc(handleMessage)\n if (timeout > 0) {\n timeoutId = setTimeout(handleTimeout, timeout)\n }\n })\n}\n\n/**\n * Create an IPC message with proper structure and metadata.\n *\n * This factory function creates properly structured IPC messages with:\n * - Unique ID for tracking\n * - Timestamp for freshness\n * - Type for routing\n * - Data payload\n *\n * @param type - The message type identifier\n * @param data - The message payload\n * @returns A properly structured IPC message\n *\n * @example\n * ```typescript\n * const handshake = createIpcMessage('handshake', {\n * version: '1.0.0',\n * pid: process.pid,\n * appName: 'socket-cli'\n * })\n * ```\n *\n * @unused Reserved for future message creation needs\n */\nexport function createIpcMessage<T = unknown>(\n type: string,\n data: T,\n): IpcMessage<T> {\n return {\n id: crypto.randomBytes(16).toString('hex'),\n timestamp: Date.now(),\n type,\n data,\n }\n}\n\n/**\n * Check if process has IPC channel available.\n *\n * This utility checks whether a process object has the necessary\n * properties for IPC communication. Used to determine if IPC\n * messaging is possible before attempting to send.\n *\n * @param process - The process object to check\n * @returns true if IPC is available, false otherwise\n *\n * @example\n * ```typescript\n * if (hasIpcChannel(childProcess)) {\n * sendIpc(childProcess, message)\n * } else {\n * // Fall back to alternative communication method\n * }\n * ```\n *\n * @unused Reserved for IPC availability detection\n */\nexport function hasIpcChannel(process: unknown): boolean {\n return Boolean(\n process &&\n typeof process === 'object' &&\n 'send' in process &&\n typeof process.send === 'function' &&\n 'channel' in process &&\n process.channel !== undefined,\n )\n}\n\n/**\n * Safely parse and validate IPC messages.\n *\n * This function performs runtime validation of incoming messages\n * to ensure they conform to the IPC message structure. It uses\n * Zod schemas for robust validation.\n *\n * ## Validation Steps:\n * 1. Check if message is an object\n * 2. Validate required fields exist\n * 3. Validate field types\n * 4. Return typed message or null\n *\n * @param message - The raw message to parse\n * @returns Parsed IPC message or null if invalid\n *\n * @example\n * ```typescript\n * const parsed = parseIpcMessage(rawMessage)\n * if (parsed) {\n * handleMessage(parsed)\n * }\n * ```\n *\n * @unused Reserved for message validation needs\n */\nexport function parseIpcMessage(message: unknown): IpcMessage | null {\n try {\n // Use Zod schema for comprehensive validation.\n const validated = Ip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AEVD,EAAO,IAAI,MAAM,yCAAyCJ,CAAW,EAAE,CAAC,CAC1E,EAYAK,EAAUhD,EAXawC,GAAwB,CACzCA,EAAQ,OAASG,IACfM,GACF,aAAaA,CAAS,EAEpBD,GACFA,EAAQ,EAEVF,EAAQN,EAAQ,IAAS,EAE7B,CAC6B,EACzBK,EAAU,IACZI,EAAY,WAAWC,EAAeL,CAAO,EAEjD,CAAC,CACH,CA0BO,SAAShD,EACdsD,EACA1B,EACe,CACf,MAAO,CACL,GAAI,EAAAT,QAAO,YAAY,EAAE,EAAE,SAAS,KAAK,EACzC,UAAW,KAAK,IAAI,EACpB,KAAAmC,EACA,KAAA1B,CACF,CACF,CAuBO,SAAS1B,EAAcwC,EAA2B,CACvD,MAAO,GACLA,GACE,OAAOA,GAAY,UACnB,SAAUA,GACV,OAAOA,EAAQ,MAAS,YACxB,YAAaA,GACbA,EAAQ,UAAY,OAE1B,CA4BO,SAAStC,EAAgBuC,EAAqC,CACnE,GAAI,CAGF,OADkB3B,EAAiB,MAAM2B,CAAO,CAElD,MAAQ,CAEN,OAAO,IACT,CACF",
|
|
6
|
+
"names": ["ipc_exports", "__export", "IpcHandshakeSchema", "cleanupIpcStubs", "createIpcChannelId", "createIpcMessage", "getIpcStubPath", "hasIpcChannel", "onIpc", "parseIpcMessage", "readIpcStub", "sendIpc", "waitForIpc", "writeIpcStub", "__toCommonJS", "import_node_crypto", "import_node_fs", "import_node_path", "import_fs", "import_paths", "import_zod", "IpcMessageSchema", "IpcStubSchema", "prefix", "crypto", "appName", "tempDir", "stubDir", "path", "ensureIpcDirectory", "filePath", "dir", "fs", "data", "stubPath", "ipcData", "validated", "content", "parsed", "ageMs", "maxAgeMs", "files", "now", "file", "stats", "isStale", "contentAge", "process", "message", "handler", "listener", "messageType", "options", "timeout", "resolve", "reject", "cleanup", "timeoutId", "handleTimeout", "type"]
|
|
7
7
|
}
|
package/dist/logger.d.ts
CHANGED
|
@@ -259,9 +259,10 @@ export declare class Logger {
|
|
|
259
259
|
* This is called automatically by logging methods.
|
|
260
260
|
*
|
|
261
261
|
* @param value - Whether the last line was blank
|
|
262
|
+
* @param stream - Optional stream to update (defaults to both streams if not bound, or target stream if bound)
|
|
262
263
|
* @returns The logger instance for chaining
|
|
263
264
|
*/
|
|
264
|
-
[lastWasBlankSymbol](value: unknown): this;
|
|
265
|
+
[lastWasBlankSymbol](value: unknown, stream?: 'stderr' | 'stdout'): this;
|
|
265
266
|
/**
|
|
266
267
|
* Logs an assertion failure message if the value is falsy.
|
|
267
268
|
*
|
package/dist/logger.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* Socket Lib - Built with esbuild */
|
|
2
|
-
var O=Object.create;var g=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var A=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty;var
|
|
2
|
+
var O=Object.create;var g=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var A=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty;var W=(e,t)=>{for(var s in t)g(e,s,{get:t[s],enumerable:!0})},_=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of P(t))!E.call(e,o)&&o!==s&&g(e,o,{get:()=>t[o],enumerable:!(n=j(t,o))||n.enumerable});return e};var L=(e,t,s)=>(s=e!=null?O(A(e)):{},_(t||!e||!e.__esModule?g(s,"default",{value:e,enumerable:!0}):s,e)),B=e=>_(g({},"__esModule",{value:!0}),e);var Y={};W(Y,{LOG_SYMBOLS:()=>w,Logger:()=>h,incLogCallCountSymbol:()=>u,lastWasBlankSymbol:()=>i,logger:()=>H});module.exports=B(Y);var S=L(require("./external/@socketregistry/is-unicode-supported")),T=L(require("./external/yoctocolors-cjs")),f=require("./objects"),d=require("./strings");const a=console,p=Reflect.apply,I=Reflect.construct;let y;function C(...e){return y===void 0&&(y=require("node:console").Console),I(y,e)}function M(){return T.default}const w=(()=>{const e={__proto__:null},t={__proto__:null},s=()=>{const n=(0,S.default)(),o=M();(0,f.objectAssign)(e,{fail:o.red(n?"\u2716":"\xD7"),info:o.blue(n?"\u2139":"i"),success:o.green(n?"\u2714":"\u221A"),warn:o.yellow(n?"\u26A0":"\u203C")}),(0,f.objectFreeze)(e);for(const c in t)delete t[c]};for(const n of Reflect.ownKeys(Reflect)){const o=Reflect[n];typeof o=="function"&&(t[n]=(...c)=>(s(),o(...c)))}return new Proxy(e,t)})(),K=["_stderrErrorHandler","_stdoutErrorHandler","assert","clear","count","countReset","createTask","debug","dir","dirxml","error","info","log","table","time","timeEnd","timeLog","trace","warn"].filter(e=>typeof a[e]=="function").map(e=>[e,a[e].bind(a)]),x={__proto__:null,writable:!0,enumerable:!1,configurable:!0},$=1e3,r=new WeakMap,G=Object.getOwnPropertySymbols(a),u=Symbol.for("logger.logCallCount++"),k=G.find(e=>e.label==="kGroupIndentWidth")??Symbol("kGroupIndentWidth"),i=Symbol.for("logger.lastWasBlank");class h{static LOG_SYMBOLS=w;#c;#t;#u;#l;#g="";#f="";#p=!1;#y=!1;#h=0;#a;#e;constructor(...t){this.#a=t;const s=t[0];if(typeof s=="object"&&s!==null?this.#e={__proto__:null,...s}:this.#e={__proto__:null},t.length)r.set(this,C(...t));else{const n=C({stdout:process.stdout,stderr:process.stderr});for(const{0:o,1:c}of K)n[o]=c;r.set(this,n)}}get stderr(){if(!this.#u){const t=new h(...this.#a);t.#c=this,t.#t="stderr",t.#e={__proto__:null,...this.#e},this.#u=t}return this.#u}get stdout(){if(!this.#l){const t=new h(...this.#a);t.#c=this,t.#t="stdout",t.#e={__proto__:null,...this.#e},this.#l=t}return this.#l}#o(){return this.#c||this}#n(t){const s=this.#o();return t==="stderr"?s.#g:s.#f}#s(t,s){const n=this.#o();t==="stderr"?n.#g=s:n.#f=s}#d(t){const s=this.#o();return t==="stderr"?s.#p:s.#y}#i(t,s){const n=this.#o();t==="stderr"?n.#p=s:n.#y=s}#w(){return this.#t||"stderr"}#k(t,s,n){const o=r.get(this),c=s.at(0),l=typeof c=="string",m=n||(t==="log"?"stdout":"stderr"),R=this.#n(m),b=l?[(0,d.applyLinePrefix)(c,{prefix:R}),...s.slice(1)]:s;return p(o[t],o,b),this[i](l&&(0,d.isBlankString)(b[0]),m),this[u](),this}#m(t){return t.replace(/^[✖✗×⚠‼✔✓√ℹ]\uFE0F?\s*/u,"")}#r(t,s){const n=r.get(this);let o=s.at(0),c;typeof o=="string"?(o=this.#m(o),c=s.slice(1)):(c=s,o="");const l=this.#n("stderr");return n.error((0,d.applyLinePrefix)(`${w[t]} ${o}`,{prefix:l}),...c),this[i](!1,"stderr"),this[u](),this}get logCallCount(){return this.#o().#h}[u](){const t=this.#o();return t.#h+=1,this}[i](t,s){return s?this.#i(s,!!t):this.#t?this.#i(this.#t,!!t):(this.#i("stderr",!!t),this.#i("stdout",!!t)),this}assert(t,...s){return r.get(this).assert(t,...s),this[i](!1),t?this:this[u]()}clearVisible(){if(this.#t)throw new Error("clearVisible() is only available on the main logger instance, not on stream-bound instances");const t=r.get(this);return t.clear(),t._stdout.isTTY&&(this[i](!0),this.#h=0),this}count(t){return r.get(this).count(t),this[i](!1),this[u]()}createTask(t){return{run:s=>{this.log(`Starting task: ${t}`);const n=s();return this.log(`Completed task: ${t}`),n}}}dedent(t=2){if(this.#t){const s=this.#n(this.#t);this.#s(this.#t,s.slice(0,-t))}else{const s=this.#n("stderr"),n=this.#n("stdout");this.#s("stderr",s.slice(0,-t)),this.#s("stdout",n.slice(0,-t))}return this}dir(t,s){return r.get(this).dir(t,s),this[i](!1),this[u]()}dirxml(...t){return r.get(this).dirxml(t),this[i](!1),this[u]()}error(...t){return this.#k("error",t)}errorNewline(){return this.#d("stderr")?this:this.error("")}fail(...t){return this.#r("fail",t)}group(...t){const{length:s}=t;return s&&p(this.log,this,t),this.indent(this[k]),s&&(this[i](!1),this[u]()),this}groupCollapsed(...t){return p(this.group,this,t)}groupEnd(){return this.dedent(this[k]),this}indent(t=2){const s=" ".repeat(Math.min(t,$));if(this.#t){const n=this.#n(this.#t);this.#s(this.#t,n+s)}else{const n=this.#n("stderr"),o=this.#n("stdout");this.#s("stderr",n+s),this.#s("stdout",o+s)}return this}info(...t){return this.#r("info",t)}log(...t){return this.#k("log",t)}logNewline(){return this.#d("stdout")?this:this.log("")}resetIndent(){return this.#t?this.#s(this.#t,""):(this.#s("stderr",""),this.#s("stdout","")),this}step(t,...s){return this.#d("stdout")||this.log(""),this.log(t,...s)}substep(t,...s){const n=` ${t}`;return this.log(n,...s)}success(...t){return this.#r("success",t)}done(...t){return this.#r("success",t)}table(t,s){return r.get(this).table(t,s),this[i](!1),this[u]()}timeEnd(t){return r.get(this).timeEnd(t),this[i](!1),this[u]()}timeLog(t,...s){return r.get(this).timeLog(t,...s),this[i](!1),this[u]()}trace(t,...s){return r.get(this).trace(t,...s),this[i](!1),this[u]()}warn(...t){return this.#r("warn",t)}write(t){return r.get(this)._stdout.write(t),this[i](!1),this}progress(t){const s=r.get(this);return(this.#w()==="stderr"?s._stderr:s._stdout).write(`\u2234 ${t}`),this[i](!1),this}clearLine(){const t=r.get(this),n=this.#w()==="stderr"?t._stderr:t._stdout;return n.isTTY?(n.cursorTo(0),n.clearLine(0)):n.write("\r\x1B[K"),this}}Object.defineProperties(h.prototype,Object.fromEntries((()=>{const e=[[k,{...x,value:2}],[Symbol.toStringTag,{__proto__:null,configurable:!0,value:"logger"}]];for(const{0:t,1:s}of Object.entries(a))if(!h.prototype[t]&&typeof s=="function"){const{[t]:n}={[t](...o){const c=r.get(this),l=c[t](...o);return l===void 0||l===c?this:l}};e.push([t,{...x,value:n}])}return e})()));const H=new h;0&&(module.exports={LOG_SYMBOLS,Logger,incLogCallCountSymbol,lastWasBlankSymbol,logger});
|
|
3
3
|
//# sourceMappingURL=logger.js.map
|
package/dist/logger.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/logger.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * @fileoverview Console logging utilities with line prefix support.\n * Provides enhanced console methods with formatted output capabilities.\n */\n\nimport isUnicodeSupported from './external/@socketregistry/is-unicode-supported'\nimport yoctocolorsCjs from './external/yoctocolors-cjs'\nimport { objectAssign, objectFreeze } from './objects'\nimport { applyLinePrefix, isBlankString } from './strings'\n\n/**\n * Log symbols for terminal output with colored indicators.\n *\n * Each symbol provides visual feedback for different message types, with\n * Unicode and ASCII fallback support.\n *\n * @example\n * ```typescript\n * import { LOG_SYMBOLS } from '@socketsecurity/lib'\n *\n * console.log(`${LOG_SYMBOLS.success} Operation completed`)\n * console.log(`${LOG_SYMBOLS.fail} Operation failed`)\n * console.log(`${LOG_SYMBOLS.warn} Warning message`)\n * console.log(`${LOG_SYMBOLS.info} Information message`)\n * ```\n */\ntype LogSymbols = {\n /** Red colored failure symbol (\u2716 or \u00D7 in ASCII) */\n fail: string\n /** Blue colored information symbol (\u2139 or i in ASCII) */\n info: string\n /** Green colored success symbol (\u2714 or \u221A in ASCII) */\n success: string\n /** Yellow colored warning symbol (\u26A0 or \u203C in ASCII) */\n warn: string\n}\n\n/**\n * Type definition for logger methods that mirror console methods.\n *\n * All methods return the logger instance for method chaining.\n */\ntype LoggerMethods = {\n [K in keyof typeof console]: (typeof console)[K] extends (\n ...args: infer A\n ) => any\n ? (...args: A) => Logger\n : (typeof console)[K]\n}\n\n/**\n * A task that can be executed with automatic start/complete logging.\n *\n * @example\n * ```typescript\n * const task = logger.createTask('Database migration')\n * task.run(() => {\n * // Migration logic here\n * })\n * // Logs: \"Starting task: Database migration\"\n * // Logs: \"Completed task: Database migration\"\n * ```\n */\ninterface Task {\n /**\n * Executes the task function with automatic logging.\n *\n * @template T - The return type of the task function\n * @param f - The function to execute\n * @returns The result of the task function\n */\n run<T>(f: () => T): T\n}\n\nexport type { LogSymbols, LoggerMethods, Task }\n\nconst globalConsole = console\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\nconst ReflectConstruct = Reflect.construct\n\nlet _Console: typeof import('console').Console | undefined\n/**\n * Construct a new Console instance.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction constructConsole(...args: unknown[]) {\n if (_Console === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n const nodeConsole = /*@__PURE__*/ require('node:console')\n _Console = nodeConsole.Console\n }\n return ReflectConstruct(\n _Console! as new (\n ...args: unknown[]\n ) => Console, // eslint-disable-line no-undef\n args,\n )\n}\n\n/**\n * Get the yoctocolors module for terminal colors.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getYoctocolors() {\n return yoctocolorsCjs\n}\n\n/**\n * Log symbols for terminal output with colored indicators.\n *\n * Provides colored Unicode symbols (\u2714, \u2716, \u26A0, \u2139) with ASCII fallbacks (\u221A, \u00D7, \u203C, i)\n * for terminals that don't support Unicode. Symbols are color-coded: green for\n * success, red for failure, yellow for warnings, blue for info.\n *\n * The symbols are lazily initialized on first access and then frozen for immutability.\n *\n * @example\n * ```typescript\n * import { LOG_SYMBOLS } from '@socketsecurity/lib'\n *\n * console.log(`${LOG_SYMBOLS.success} Build completed`) // Green \u2714\n * console.log(`${LOG_SYMBOLS.fail} Build failed`) // Red \u2716\n * console.log(`${LOG_SYMBOLS.warn} Deprecated API used`) // Yellow \u26A0\n * console.log(`${LOG_SYMBOLS.info} Starting process`) // Blue \u2139\n * ```\n */\nexport const LOG_SYMBOLS = /*@__PURE__*/ (() => {\n const target: Record<string, string> = {\n __proto__: null,\n } as unknown as Record<string, string>\n // Mutable handler to simulate a frozen target.\n const handler: ProxyHandler<Record<string, string>> = {\n __proto__: null,\n } as unknown as ProxyHandler<Record<string, string>>\n const init = () => {\n const supported = isUnicodeSupported()\n const colors = getYoctocolors()\n objectAssign(target, {\n fail: colors.red(supported ? '\u2716' : '\u00D7'),\n info: colors.blue(supported ? '\u2139' : 'i'),\n success: colors.green(supported ? '\u2714' : '\u221A'),\n warn: colors.yellow(supported ? '\u26A0' : '\u203C'),\n })\n objectFreeze(target)\n // The handler of a Proxy is mutable after proxy instantiation.\n // We delete the traps to defer to native behavior.\n for (const trapName in handler) {\n delete handler[trapName as keyof ProxyHandler<Record<string, string>>]\n }\n }\n for (const trapName of Reflect.ownKeys(Reflect)) {\n const fn = (Reflect as Record<PropertyKey, unknown>)[trapName]\n if (typeof fn === 'function') {\n ;(handler as Record<string, (...args: unknown[]) => unknown>)[\n trapName as string\n ] = (...args: unknown[]) => {\n init()\n return fn(...args)\n }\n }\n }\n return new Proxy(target, handler)\n})()\n\nconst boundConsoleEntries = [\n // Add bound properties from console[kBindProperties](ignoreErrors, colorMode, groupIndentation).\n // https://github.com/nodejs/node/blob/v24.0.1/lib/internal/console/constructor.js#L230-L265\n '_stderrErrorHandler',\n '_stdoutErrorHandler',\n // Add methods that need to be bound to function properly.\n 'assert',\n 'clear',\n 'count',\n 'countReset',\n 'createTask',\n 'debug',\n 'dir',\n 'dirxml',\n 'error',\n // Skip group methods because in at least Node 20 with the Node --frozen-intrinsics\n // flag it triggers a readonly property for Symbol(kGroupIndent). Instead, we\n // implement these methods ourselves.\n //'group',\n //'groupCollapsed',\n //'groupEnd',\n 'info',\n 'log',\n 'table',\n 'time',\n 'timeEnd',\n 'timeLog',\n 'trace',\n 'warn',\n]\n .filter(n => typeof (globalConsole as any)[n] === 'function')\n .map(n => [n, (globalConsole as any)[n].bind(globalConsole)])\n\nconst consolePropAttributes = {\n __proto__: null,\n writable: true,\n enumerable: false,\n configurable: true,\n}\nconst maxIndentation = 1000\nconst privateConsole = new WeakMap()\n\nconst consoleSymbols = Object.getOwnPropertySymbols(globalConsole)\n\n/**\n * Symbol for incrementing the internal log call counter.\n *\n * This is an internal symbol used to track the number of times logging\n * methods have been called on a logger instance.\n */\nexport const incLogCallCountSymbol = Symbol.for('logger.logCallCount++')\n\nconst kGroupIndentationWidthSymbol =\n consoleSymbols.find(s => (s as any).label === 'kGroupIndentWidth') ??\n Symbol('kGroupIndentWidth')\n\n/**\n * Symbol for tracking whether the last logged line was blank.\n *\n * This is used internally to prevent multiple consecutive blank lines\n * and to determine whether to add spacing before certain messages.\n */\nexport const lastWasBlankSymbol = Symbol.for('logger.lastWasBlank')\n\n/**\n * Enhanced console logger with indentation, colored symbols, and stream management.\n *\n * Provides a fluent API for logging with automatic indentation tracking, colored\n * status symbols, separate stderr/stdout management, and method chaining. All\n * methods return `this` for easy chaining.\n *\n * Features:\n * - Automatic line prefixing with indentation\n * - Colored status symbols (success, fail, warn, info)\n * - Separate indentation tracking for stderr and stdout\n * - Stream-bound logger instances via `.stderr` and `.stdout`\n * - Group/indentation management\n * - Progress indicators with clearable lines\n * - Task execution with automatic logging\n *\n * @example\n * ```typescript\n * import { logger } from '@socketsecurity/lib'\n *\n * // Basic logging with symbols\n * logger.success('Build completed')\n * logger.fail('Build failed')\n * logger.warn('Deprecated API')\n * logger.info('Starting process')\n *\n * // Indentation and grouping\n * logger.log('Processing files:')\n * logger.indent()\n * logger.log('file1.js')\n * logger.log('file2.js')\n * logger.dedent()\n *\n * // Method chaining\n * logger\n * .log('Step 1')\n * .indent()\n * .log('Substep 1.1')\n * .log('Substep 1.2')\n * .dedent()\n * .log('Step 2')\n *\n * // Stream-specific logging\n * logger.stdout.log('Normal output')\n * logger.stderr.error('Error message')\n *\n * // Progress indicators\n * logger.progress('Processing...')\n * // ... do work ...\n * logger.clearLine()\n * logger.success('Done')\n *\n * // Task execution\n * const task = logger.createTask('Migration')\n * task.run(() => {\n * // Migration logic\n * })\n * ```\n */\n/*@__PURE__*/\nexport class Logger {\n /**\n * Static reference to log symbols for convenience.\n *\n * @example\n * ```typescript\n * console.log(`${Logger.LOG_SYMBOLS.success} Done`)\n * ```\n */\n static LOG_SYMBOLS = LOG_SYMBOLS\n\n #parent?: Logger\n #boundStream?: 'stderr' | 'stdout'\n #stderrLogger?: Logger\n #stdoutLogger?: Logger\n #stderrIndention = ''\n #stdoutIndention = ''\n #lastWasBlank = false\n #logCallCount = 0\n #constructorArgs: unknown[]\n #options: Record<string, unknown>\n\n /**\n * Creates a new Logger instance.\n *\n * When called without arguments, creates a logger using the default\n * `process.stdout` and `process.stderr` streams. Can accept custom\n * console constructor arguments for advanced use cases.\n *\n * @param args - Optional console constructor arguments\n *\n * @example\n * ```typescript\n * // Default logger\n * const logger = new Logger()\n *\n * // Custom streams (advanced)\n * const customLogger = new Logger({\n * stdout: customWritableStream,\n * stderr: customErrorStream\n * })\n * ```\n */\n constructor(...args: unknown[]) {\n // Store constructor args for child loggers\n this.#constructorArgs = args\n\n // Store options if provided (for future extensibility)\n const options = args['0']\n if (typeof options === 'object' && options !== null) {\n this.#options = { __proto__: null, ...options }\n } else {\n this.#options = { __proto__: null }\n }\n\n if (args.length) {\n privateConsole.set(this, constructConsole(...args))\n } else {\n // Create a new console that acts like the builtin one so that it will\n // work with Node's --frozen-intrinsics flag.\n const con = constructConsole({\n stdout: process.stdout,\n stderr: process.stderr,\n }) as typeof console & Record<string, unknown>\n for (const { 0: key, 1: method } of boundConsoleEntries) {\n con[key] = method\n }\n privateConsole.set(this, con)\n }\n }\n\n /**\n * Gets a logger instance bound exclusively to stderr.\n *\n * All logging operations on this instance will write to stderr only.\n * Indentation is tracked separately from stdout. The instance is\n * cached and reused on subsequent accesses.\n *\n * @returns A logger instance bound to stderr\n *\n * @example\n * ```typescript\n * // Write errors to stderr\n * logger.stderr.error('Configuration invalid')\n * logger.stderr.warn('Using fallback settings')\n *\n * // Indent only affects stderr\n * logger.stderr.indent()\n * logger.stderr.error('Nested error details')\n * logger.stderr.dedent()\n * ```\n */\n get stderr(): Logger {\n if (!this.#stderrLogger) {\n // Pass parent's constructor args to maintain config\n const instance = new Logger(...this.#constructorArgs)\n instance.#parent = this\n instance.#boundStream = 'stderr'\n instance.#options = { __proto__: null, ...this.#options }\n this.#stderrLogger = instance\n }\n return this.#stderrLogger\n }\n\n /**\n * Gets a logger instance bound exclusively to stdout.\n *\n * All logging operations on this instance will write to stdout only.\n * Indentation is tracked separately from stderr. The instance is\n * cached and reused on subsequent accesses.\n *\n * @returns A logger instance bound to stdout\n *\n * @example\n * ```typescript\n * // Write normal output to stdout\n * logger.stdout.log('Processing started')\n * logger.stdout.log('Items processed: 42')\n *\n * // Indent only affects stdout\n * logger.stdout.indent()\n * logger.stdout.log('Detailed output')\n * logger.stdout.dedent()\n * ```\n */\n get stdout(): Logger {\n if (!this.#stdoutLogger) {\n // Pass parent's constructor args to maintain config\n const instance = new Logger(...this.#constructorArgs)\n instance.#parent = this\n instance.#boundStream = 'stdout'\n instance.#options = { __proto__: null, ...this.#options }\n this.#stdoutLogger = instance\n }\n return this.#stdoutLogger\n }\n\n /**\n * Get the root logger (for accessing shared indentation state).\n * @private\n */\n #getRoot(): Logger {\n return this.#parent || this\n }\n\n /**\n * Get indentation for a specific stream.\n * @private\n */\n #getIndent(stream: 'stderr' | 'stdout'): string {\n const root = this.#getRoot()\n return stream === 'stderr' ? root.#stderrIndention : root.#stdoutIndention\n }\n\n /**\n * Set indentation for a specific stream.\n * @private\n */\n #setIndent(stream: 'stderr' | 'stdout', value: string): void {\n const root = this.#getRoot()\n if (stream === 'stderr') {\n root.#stderrIndention = value\n } else {\n root.#stdoutIndention = value\n }\n }\n\n /**\n * Get the target stream for this logger instance.\n * @private\n */\n #getTargetStream(): 'stderr' | 'stdout' {\n return this.#boundStream || 'stderr'\n }\n\n /**\n * Apply a console method with indentation.\n * @private\n */\n #apply(\n methodName: string,\n args: unknown[],\n stream?: 'stderr' | 'stdout',\n ): this {\n const con = privateConsole.get(this) as typeof console &\n Record<string, unknown>\n const text = args.at(0)\n const hasText = typeof text === 'string'\n // Determine which stream this method writes to\n const targetStream = stream || (methodName === 'log' ? 'stdout' : 'stderr')\n const indent = this.#getIndent(targetStream)\n const logArgs = hasText\n ? [applyLinePrefix(text, { prefix: indent }), ...args.slice(1)]\n : args\n ReflectApply(\n con[methodName] as (...args: unknown[]) => unknown,\n con,\n logArgs,\n )\n this[lastWasBlankSymbol](hasText && isBlankString(logArgs[0]))\n ;(this as any)[incLogCallCountSymbol]()\n return this\n }\n\n /**\n * Strip log symbols from the start of text.\n * @private\n */\n #stripSymbols(text: string): string {\n // Strip both unicode and emoji forms of log symbols from the start.\n // Matches: \u2716, \u2717, \u00D7, \u2716\uFE0F, \u26A0, \u203C, \u26A0\uFE0F, \u2714, \u2713, \u221A, \u2714\uFE0F, \u2713\uFE0F, \u2139, \u2139\uFE0F\n // Also handles variation selectors (U+FE0F) and whitespace after symbol.\n // Note: We don't strip standalone 'i' to avoid breaking words like 'info'.\n return text.replace(/^[\u2716\u2717\u00D7\u26A0\u203C\u2714\u2713\u221A\u2139]\\uFE0F?\\s*/u, '')\n }\n\n /**\n * Apply a method with a symbol prefix.\n * @private\n */\n #symbolApply(symbolType: string, args: unknown[]): this {\n const con = privateConsole.get(this)\n let text = args.at(0)\n // biome-ignore lint/suspicious/noImplicitAnyLet: Flexible argument handling.\n let extras\n if (typeof text === 'string') {\n text = this.#stripSymbols(text)\n extras = args.slice(1)\n } else {\n extras = args\n text = ''\n }\n // Note: Meta status messages (info/fail/etc) always go to stderr.\n const indent = this.#getIndent('stderr')\n con.error(\n applyLinePrefix(`${LOG_SYMBOLS[symbolType]} ${text}`, {\n prefix: indent,\n }),\n ...extras,\n )\n this.#lastWasBlank = false\n ;(this as any)[incLogCallCountSymbol]()\n return this\n }\n\n /**\n * Gets the total number of log calls made on this logger instance.\n *\n * Tracks all logging method calls including `log()`, `error()`, `warn()`,\n * `success()`, `fail()`, etc. Useful for testing and monitoring logging activity.\n *\n * @returns The number of times logging methods have been called\n *\n * @example\n * ```typescript\n * logger.log('Message 1')\n * logger.error('Message 2')\n * console.log(logger.logCallCount) // 2\n * ```\n */\n get logCallCount() {\n return this.#logCallCount\n }\n\n /**\n * Increments the internal log call counter.\n *\n * This is called automatically by logging methods and should not\n * be called directly in normal usage.\n *\n * @returns The logger instance for chaining\n */\n [incLogCallCountSymbol]() {\n this.#logCallCount += 1\n return this\n }\n\n /**\n * Sets whether the last logged line was blank.\n *\n * Used internally to track blank lines and prevent duplicate spacing.\n * This is called automatically by logging methods.\n *\n * @param value - Whether the last line was blank\n * @returns The logger instance for chaining\n */\n [lastWasBlankSymbol](value: unknown): this {\n this.#lastWasBlank = !!value\n return this\n }\n\n /**\n * Logs an assertion failure message if the value is falsy.\n *\n * Works like `console.assert()` but returns the logger for chaining.\n * If the value is truthy, nothing is logged. If falsy, logs an error\n * message with an assertion failure.\n *\n * @param value - The value to test\n * @param message - Optional message and additional arguments to log\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.assert(true, 'This will not log')\n * logger.assert(false, 'Assertion failed: value is false')\n * logger.assert(items.length > 0, 'No items found')\n * ```\n */\n assert(value: unknown, ...message: unknown[]): this {\n const con = privateConsole.get(this)\n con.assert(value, ...message)\n this[lastWasBlankSymbol](false)\n return value ? this : this[incLogCallCountSymbol]()\n }\n\n /**\n * Clears the visible terminal screen.\n *\n * Only available on the main logger instance, not on stream-bound instances\n * (`.stderr` or `.stdout`). Resets the log call count and blank line tracking\n * if the output is a TTY.\n *\n * @returns The logger instance for chaining\n * @throws {Error} If called on a stream-bound logger instance\n *\n * @example\n * ```typescript\n * logger.log('Some output')\n * logger.clearVisible() // Screen is now clear\n *\n * // Error: Can't call on stream-bound instance\n * logger.stderr.clearVisible() // throws\n * ```\n */\n clearVisible() {\n if (this.#boundStream) {\n throw new Error(\n 'clearVisible() is only available on the main logger instance, not on stream-bound instances',\n )\n }\n const con = privateConsole.get(this)\n con.clear()\n if ((con as any)._stdout.isTTY) {\n ;(this as any)[lastWasBlankSymbol](true)\n this.#logCallCount = 0\n }\n return this\n }\n\n /**\n * Increments and logs a counter for the given label.\n *\n * Each unique label maintains its own counter. Works like `console.count()`.\n *\n * @param label - Optional label for the counter\n * @default 'default'\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.count('requests') // requests: 1\n * logger.count('requests') // requests: 2\n * logger.count('errors') // errors: 1\n * logger.count() // default: 1\n * ```\n */\n count(label?: string | undefined): this {\n const con = privateConsole.get(this)\n con.count(label)\n this[lastWasBlankSymbol](false)\n return this[incLogCallCountSymbol]()\n }\n\n /**\n * Creates a task that logs start and completion messages automatically.\n *\n * Returns a task object with a `run()` method that executes the provided\n * function and logs \"Starting task: {name}\" before execution and\n * \"Completed task: {name}\" after completion.\n *\n * @param name - The name of the task\n * @returns A task object with a `run()` method\n *\n * @example\n * ```typescript\n * const task = logger.createTask('Database Migration')\n * const result = task.run(() => {\n * // Logs: \"Starting task: Database Migration\"\n * migrateDatabase()\n * return 'success'\n * // Logs: \"Completed task: Database Migration\"\n * })\n * console.log(result) // 'success'\n * ```\n */\n createTask(name: string): Task {\n return {\n run: <T>(f: () => T): T => {\n this.log(`Starting task: ${name}`)\n const result = f()\n this.log(`Completed task: ${name}`)\n return result\n },\n }\n }\n\n /**\n * Decreases the indentation level by removing spaces from the prefix.\n *\n * When called on the main logger, affects both stderr and stdout indentation.\n * When called on a stream-bound logger (`.stderr` or `.stdout`), affects\n * only that stream's indentation.\n *\n * @param spaces - Number of spaces to remove from indentation\n * @default 2\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.indent()\n * logger.log('Indented')\n * logger.dedent()\n * logger.log('Back to normal')\n *\n * // Remove custom amount\n * logger.indent(4)\n * logger.log('Four spaces')\n * logger.dedent(4)\n *\n * // Stream-specific dedent\n * logger.stdout.indent()\n * logger.stdout.log('Indented stdout')\n * logger.stdout.dedent()\n * ```\n */\n dedent(spaces = 2) {\n if (this.#boundStream) {\n // Only affect bound stream\n const current = this.#getIndent(this.#boundStream)\n this.#setIndent(this.#boundStream, current.slice(0, -spaces))\n } else {\n // Affect both streams\n const stderrCurrent = this.#getIndent('stderr')\n const stdoutCurrent = this.#getIndent('stdout')\n this.#setIndent('stderr', stderrCurrent.slice(0, -spaces))\n this.#setIndent('stdout', stdoutCurrent.slice(0, -spaces))\n }\n return this\n }\n\n /**\n * Displays an object's properties in a formatted way.\n *\n * Works like `console.dir()` with customizable options for depth,\n * colors, etc. Useful for inspecting complex objects.\n *\n * @param obj - The object to display\n * @param options - Optional formatting options (Node.js inspect options)\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * const obj = { a: 1, b: { c: 2, d: { e: 3 } } }\n * logger.dir(obj)\n * logger.dir(obj, { depth: 1 }) // Limit nesting depth\n * logger.dir(obj, { colors: true }) // Enable colors\n * ```\n */\n dir(obj: unknown, options?: unknown | undefined): this {\n const con = privateConsole.get(this)\n con.dir(obj, options)\n this[lastWasBlankSymbol](false)\n return this[incLogCallCountSymbol]()\n }\n\n /**\n * Displays data as XML/HTML in a formatted way.\n *\n * Works like `console.dirxml()`. In Node.js, behaves the same as `dir()`.\n *\n * @param data - The data to display\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.dirxml(document.body) // In browser environments\n * logger.dirxml(xmlObject) // In Node.js\n * ```\n */\n dirxml(...data: unknown[]): this {\n const con = privateConsole.get(this)\n con.dirxml(data)\n this[lastWasBlankSymbol](false)\n return this[incLogCallCountSymbol]()\n }\n\n /**\n * Logs an error message to stderr.\n *\n * Automatically applies current indentation. All arguments are formatted\n * and logged like `console.error()`.\n *\n * @param args - Message and additional arguments to log\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.error('Build failed')\n * logger.error('Error code:', 500)\n * logger.error('Details:', { message: 'Not found' })\n * ```\n */\n error(...args: unknown[]): this {\n return this.#apply('error', args)\n }\n\n /**\n * Logs a newline to stderr only if the last line wasn't already blank.\n *\n * Prevents multiple consecutive blank lines. Useful for adding spacing\n * between sections without creating excessive whitespace.\n *\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.error('Error message')\n * logger.errorNewline() // Adds blank line\n * logger.errorNewline() // Does nothing (already blank)\n * logger.error('Next section')\n * ```\n */\n errorNewline() {\n return this.#lastWasBlank ? this : this.error('')\n }\n\n /**\n * Logs a failure message with a red colored fail symbol.\n *\n * Automatically prefixes the message with `LOG_SYMBOLS.fail` (red \u2716).\n * Always outputs to stderr. If the message starts with an existing\n * symbol, it will be stripped and replaced.\n *\n * @param args - Message and additional arguments to log\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.fail('Build failed')\n * logger.fail('Test suite failed:', { passed: 5, failed: 3 })\n * ```\n */\n fail(...args: unknown[]): this {\n return this.#symbolApply('fail', args)\n }\n\n /**\n * Starts a new indented log group.\n *\n * If a label is provided, it's logged before increasing indentation.\n * Groups can be nested. Each group increases indentation by the\n * `kGroupIndentWidth` (default 2 spaces). Call `groupEnd()` to close.\n *\n * @param label - Optional label to display before the group\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.group('Processing files:')\n * logger.log('file1.js')\n * logger.log('file2.js')\n * logger.groupEnd()\n *\n * // Nested groups\n * logger.group('Outer')\n * logger.log('Outer content')\n * logger.group('Inner')\n * logger.log('Inner content')\n * logger.groupEnd()\n * logger.groupEnd()\n * ```\n */\n group(...label: unknown[]): this {\n const { length } = label\n if (length) {\n ReflectApply(this.log, this, label)\n }\n this.indent((this as any)[kGroupIndentationWidthSymbol])\n if (length) {\n ;(this as any)[lastWasBlankSymbol](false)\n ;(this as any)[incLogCallCountSymbol]()\n }\n return this\n }\n\n /**\n * Starts a new collapsed log group (alias for `group()`).\n *\n * In browser consoles, this creates a collapsed group. In Node.js,\n * it behaves identically to `group()`.\n *\n * @param label - Optional label to display before the group\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.groupCollapsed('Details')\n * logger.log('Hidden by default in browsers')\n * logger.groupEnd()\n * ```\n */\n // groupCollapsed is an alias of group.\n // https://nodejs.org/api/console.html#consolegroupcollapsed\n groupCollapsed(...label: unknown[]): this {\n return ReflectApply(this.group, this, label)\n }\n\n /**\n * Ends the current log group and decreases indentation.\n *\n * Must be called once for each `group()` or `groupCollapsed()` call\n * to properly close the group and restore indentation.\n *\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.group('Group 1')\n * logger.log('Content')\n * logger.groupEnd() // Closes 'Group 1'\n * ```\n */\n groupEnd() {\n this.dedent((this as any)[kGroupIndentationWidthSymbol])\n return this\n }\n\n /**\n * Increases the indentation level by adding spaces to the prefix.\n *\n * When called on the main logger, affects both stderr and stdout indentation.\n * When called on a stream-bound logger (`.stderr` or `.stdout`), affects\n * only that stream's indentation. Maximum indentation is 1000 spaces.\n *\n * @param spaces - Number of spaces to add to indentation\n * @default 2\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.log('Level 0')\n * logger.indent()\n * logger.log('Level 1')\n * logger.indent()\n * logger.log('Level 2')\n * logger.dedent()\n * logger.dedent()\n *\n * // Custom indent amount\n * logger.indent(4)\n * logger.log('Indented 4 spaces')\n * logger.dedent(4)\n *\n * // Stream-specific indent\n * logger.stdout.indent()\n * logger.stdout.log('Only stdout is indented')\n * ```\n */\n indent(spaces = 2) {\n const spacesToAdd = ' '.repeat(Math.min(spaces, maxIndentation))\n if (this.#boundStream) {\n // Only affect bound stream\n const current = this.#getIndent(this.#boundStream)\n this.#setIndent(this.#boundStream, current + spacesToAdd)\n } else {\n // Affect both streams\n const stderrCurrent = this.#getIndent('stderr')\n const stdoutCurrent = this.#getIndent('stdout')\n this.#setIndent('stderr', stderrCurrent + spacesToAdd)\n this.#setIndent('stdout', stdoutCurrent + spacesToAdd)\n }\n return this\n }\n\n /**\n * Logs an informational message with a blue colored info symbol.\n *\n * Automatically prefixes the message with `LOG_SYMBOLS.info` (blue \u2139).\n * Always outputs to stderr. If the message starts with an existing\n * symbol, it will be stripped and replaced.\n *\n * @param args - Message and additional arguments to log\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.info('Starting build process')\n * logger.info('Configuration loaded:', config)\n * logger.info('Using cache directory:', cacheDir)\n * ```\n */\n info(...args: unknown[]): this {\n return this.#symbolApply('info', args)\n }\n\n /**\n * Logs a message to stdout.\n *\n * Automatically applies current indentation. All arguments are formatted\n * and logged like `console.log()`. This is the primary method for\n * standard output.\n *\n * @param args - Message and additional arguments to log\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.log('Processing complete')\n * logger.log('Items processed:', 42)\n * logger.log('Results:', { success: true, count: 10 })\n *\n * // Method chaining\n * logger.log('Step 1').log('Step 2').log('Step 3')\n * ```\n */\n log(...args: unknown[]): this {\n return this.#apply('log', args)\n }\n\n /**\n * Logs a newline to stdout only if the last line wasn't already blank.\n *\n * Prevents multiple consecutive blank lines. Useful for adding spacing\n * between sections without creating excessive whitespace.\n *\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.log('Section 1')\n * logger.logNewline() // Adds blank line\n * logger.logNewline() // Does nothing (already blank)\n * logger.log('Section 2')\n * ```\n */\n logNewline() {\n return this.#lastWasBlank ? this : this.log('')\n }\n\n /**\n * Resets all indentation to zero.\n *\n * When called on the main logger, resets both stderr and stdout indentation.\n * When called on a stream-bound logger (`.stderr` or `.stdout`), resets\n * only that stream's indentation.\n *\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.indent().indent().indent()\n * logger.log('Very indented')\n * logger.resetIndent()\n * logger.log('Back to zero indentation')\n *\n * // Reset only stdout\n * logger.stdout.resetIndent()\n * ```\n */\n resetIndent() {\n if (this.#boundStream) {\n // Only reset bound stream\n this.#setIndent(this.#boundStream, '')\n } else {\n // Reset both streams\n this.#setIndent('stderr', '')\n this.#setIndent('stdout', '')\n }\n return this\n }\n\n /**\n * Logs a main step message with a blank line before it (stateless).\n *\n * Automatically adds a blank line before the message unless the last\n * line was already blank. Useful for marking major steps in a process\n * with clear visual separation.\n *\n * @param msg - The step message to log\n * @param extras - Additional arguments to log\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.step('Building project')\n * logger.log('Compiling TypeScript...')\n * logger.step('Running tests')\n * logger.log('Running test suite...')\n * // Output:\n * // [blank line]\n * // Building project\n * // Compiling TypeScript...\n * // [blank line]\n * // Running tests\n * // Running test suite...\n * ```\n */\n step(msg: string, ...extras: unknown[]): this {\n // Add blank line before the step message.\n if (!this.#lastWasBlank) {\n // Use this.log() to properly track the blank line.\n this.log('')\n }\n // Let log() handle all tracking.\n return this.log(msg, ...extras)\n }\n\n /**\n * Logs an indented substep message (stateless).\n *\n * Adds a 2-space indent to the message without affecting the logger's\n * indentation state. Useful for showing sub-items under a main step.\n *\n * @param msg - The substep message to log\n * @param extras - Additional arguments to log\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.log('Installing dependencies:')\n * logger.substep('Installing react')\n * logger.substep('Installing typescript')\n * logger.substep('Installing eslint')\n * // Output:\n * // Installing dependencies:\n * // Installing react\n * // Installing typescript\n * // Installing eslint\n * ```\n */\n substep(msg: string, ...extras: unknown[]): this {\n // Add 2-space indent to the message.\n const indentedMsg = ` ${msg}`\n // Let log() handle all tracking.\n return this.log(indentedMsg, ...extras)\n }\n\n /**\n * Logs a success message with a green colored success symbol.\n *\n * Automatically prefixes the message with `LOG_SYMBOLS.success` (green \u2714).\n * Always outputs to stderr. If the message starts with an existing\n * symbol, it will be stripped and replaced.\n *\n * @param args - Message and additional arguments to log\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.success('Build completed')\n * logger.success('Tests passed:', { total: 42, passed: 42 })\n * logger.success('Deployment successful')\n * ```\n */\n success(...args: unknown[]): this {\n return this.#symbolApply('success', args)\n }\n\n /**\n * Logs a completion message with a success symbol (alias for `success()`).\n *\n * Provides semantic clarity when marking something as \"done\". Does NOT\n * automatically clear the current line - call `clearLine()` first if\n * needed after using `progress()`.\n *\n * @param args - Message and additional arguments to log\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.done('Task completed')\n *\n * // After progress indicator\n * logger.progress('Processing...')\n * // ... do work ...\n * logger.clearLine()\n * logger.done('Processing complete')\n * ```\n */\n done(...args: unknown[]): this {\n return this.#symbolApply('success', args)\n }\n\n /**\n * Displays data in a table format.\n *\n * Works like `console.table()`. Accepts arrays of objects or\n * objects with nested objects. Optionally specify which properties\n * to include in the table.\n *\n * @param tabularData - The data to display as a table\n * @param properties - Optional array of property names to include\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * // Array of objects\n * logger.table([\n * { name: 'Alice', age: 30 },\n * { name: 'Bob', age: 25 }\n * ])\n *\n * // Specify properties to show\n * logger.table(users, ['name', 'email'])\n *\n * // Object with nested objects\n * logger.table({\n * user1: { name: 'Alice', age: 30 },\n * user2: { name: 'Bob', age: 25 }\n * })\n * ```\n */\n table(\n tabularData: unknown,\n properties?: readonly string[] | undefined,\n ): this {\n const con = privateConsole.get(this)\n con.table(tabularData, properties)\n this[lastWasBlankSymbol](false)\n return this[incLogCallCountSymbol]()\n }\n\n /**\n * Ends a timer and logs the elapsed time.\n *\n * Logs the duration since `console.time()` was called with the same\n * label. The timer is stopped and removed.\n *\n * @param label - Optional label for the timer\n * @default 'default'\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * console.time('operation')\n * // ... do work ...\n * logger.timeEnd('operation')\n * // Logs: \"operation: 123.456ms\"\n *\n * console.time()\n * // ... do work ...\n * logger.timeEnd()\n * // Logs: \"default: 123.456ms\"\n * ```\n */\n timeEnd(label?: string | undefined): this {\n const con = privateConsole.get(this)\n con.timeEnd(label)\n this[lastWasBlankSymbol](false)\n return this[incLogCallCountSymbol]()\n }\n\n /**\n * Logs the current value of a timer without stopping it.\n *\n * Logs the duration since `console.time()` was called with the same\n * label, but keeps the timer running. Can include additional data\n * to log alongside the time.\n *\n * @param label - Optional label for the timer\n * @param data - Additional data to log with the time\n * @default 'default'\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * console.time('process')\n * // ... partial work ...\n * logger.timeLog('process', 'Checkpoint 1')\n * // Logs: \"process: 123.456ms Checkpoint 1\"\n * // ... more work ...\n * logger.timeLog('process', 'Checkpoint 2')\n * // Logs: \"process: 234.567ms Checkpoint 2\"\n * console.timeEnd('process')\n * ```\n */\n timeLog(label?: string | undefined, ...data: unknown[]): this {\n const con = privateConsole.get(this)\n con.timeLog(label, ...data)\n this[lastWasBlankSymbol](false)\n return this[incLogCallCountSymbol]()\n }\n\n /**\n * Logs a stack trace to the console.\n *\n * Works like `console.trace()`. Shows the call stack leading to\n * where this method was called. Useful for debugging.\n *\n * @param message - Optional message to display with the trace\n * @param args - Additional arguments to log\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * function debugFunction() {\n * logger.trace('Debug point reached')\n * }\n *\n * logger.trace('Trace from here')\n * logger.trace('Error context:', { userId: 123 })\n * ```\n */\n trace(message?: unknown | undefined, ...args: unknown[]): this {\n const con = privateConsole.get(this)\n con.trace(message, ...args)\n this[lastWasBlankSymbol](false)\n return this[incLogCallCountSymbol]()\n }\n\n /**\n * Logs a warning message with a yellow colored warning symbol.\n *\n * Automatically prefixes the message with `LOG_SYMBOLS.warn` (yellow \u26A0).\n * Always outputs to stderr. If the message starts with an existing\n * symbol, it will be stripped and replaced.\n *\n * @param args - Message and additional arguments to log\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.warn('Deprecated API used')\n * logger.warn('Low memory:', { available: '100MB' })\n * logger.warn('Missing optional configuration')\n * ```\n */\n warn(...args: unknown[]): this {\n return this.#symbolApply('warn', args)\n }\n\n /**\n * Writes text directly to stdout without a newline or indentation.\n *\n * Useful for progress indicators or custom formatting where you need\n * low-level control. Does not apply any indentation or formatting.\n *\n * @param text - The text to write\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.write('Processing... ')\n * // ... do work ...\n * logger.write('done\\n')\n *\n * // Build a line incrementally\n * logger.write('Step 1')\n * logger.write('... Step 2')\n * logger.write('... Step 3\\n')\n * ```\n */\n write(text: string): this {\n const con = privateConsole.get(this)\n con._stdout.write(text)\n this[lastWasBlankSymbol](false)\n return this\n }\n\n /**\n * Shows a progress indicator that can be cleared with `clearLine()`.\n *\n * Displays a simple status message with a '\u2234' prefix. Does not include\n * animation or spinner. Intended to be cleared once the operation completes.\n * The output stream (stderr or stdout) depends on whether the logger is\n * stream-bound.\n *\n * @param text - The progress message to display\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.progress('Processing files...')\n * // ... do work ...\n * logger.clearLine()\n * logger.success('Files processed')\n *\n * // Stream-specific progress\n * logger.stdout.progress('Loading...')\n * // ... do work ...\n * logger.stdout.clearLine()\n * logger.stdout.log('Done')\n * ```\n */\n progress(text: string): this {\n const con = privateConsole.get(this)\n const stream = this.#getTargetStream()\n const streamObj = stream === 'stderr' ? con._stderr : con._stdout\n streamObj.write(`\u2234 ${text}`)\n this[lastWasBlankSymbol](false)\n return this\n }\n\n /**\n * Clears the current line in the terminal.\n *\n * Moves the cursor to the beginning of the line and clears all content.\n * Works in both TTY and non-TTY environments. Useful for clearing\n * progress indicators created with `progress()`.\n *\n * The stream to clear (stderr or stdout) depends on whether the logger\n * is stream-bound.\n *\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.progress('Loading...')\n * // ... do work ...\n * logger.clearLine()\n * logger.success('Loaded')\n *\n * // Clear multiple progress updates\n * for (const file of files) {\n * logger.progress(`Processing ${file}`)\n * processFile(file)\n * logger.clearLine()\n * }\n * logger.success('All files processed')\n * ```\n */\n clearLine(): this {\n const con = privateConsole.get(this)\n const stream = this.#getTargetStream()\n const streamObj = stream === 'stderr' ? con._stderr : con._stdout\n if (streamObj.isTTY) {\n streamObj.cursorTo(0)\n streamObj.clearLine(0)\n } else {\n streamObj.write('\\r\\x1b[K')\n }\n return this\n }\n}\n\nObject.defineProperties(\n Logger.prototype,\n Object.fromEntries(\n (() => {\n const entries: Array<[string | symbol, PropertyDescriptor]> = [\n [\n kGroupIndentationWidthSymbol,\n {\n ...consolePropAttributes,\n value: 2,\n },\n ],\n [\n Symbol.toStringTag,\n {\n __proto__: null,\n configurable: true,\n value: 'logger',\n } as PropertyDescriptor,\n ],\n ]\n for (const { 0: key, 1: value } of Object.entries(globalConsole)) {\n if (!(Logger.prototype as any)[key] && typeof value === 'function') {\n // Dynamically name the log method without using Object.defineProperty.\n const { [key]: func } = {\n [key](...args: unknown[]) {\n const con = privateConsole.get(this)\n const result = (con as any)[key](...args)\n return result === undefined || result === con ? this : result\n },\n }\n entries.push([\n key,\n {\n ...consolePropAttributes,\n value: func,\n },\n ])\n }\n }\n return entries\n })(),\n ),\n)\n\n/**\n * Default logger instance for the application.\n *\n * A pre-configured `Logger` instance that uses the standard `process.stdout`\n * and `process.stderr` streams. This is the recommended logger to import\n * and use throughout your application.\n *\n * @example\n * ```typescript\n * import { logger } from '@socketsecurity/lib'\n *\n * logger.log('Application started')\n * logger.success('Configuration loaded')\n * logger.indent()\n * logger.log('Using port 3000')\n * logger.dedent()\n * ```\n */\nexport const logger = new Logger()\n"],
|
|
5
|
-
"mappings": ";6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,EAAA,WAAAC,EAAA,0BAAAC,EAAA,uBAAAC,EAAA,WAAAC,IAAA,eAAAC,EAAAP,GAKA,IAAAQ,EAA+B,8DAC/BC,EAA2B,yCAC3BC,EAA2C,qBAC3CC,EAA+C,qBAoE/C,MAAMC,EAAgB,QAKhBC,EAAe,QAAQ,MACvBC,EAAmB,QAAQ,UAEjC,IAAIC,EAMJ,SAASC,KAAoBC,EAAiB,CAC5C,OAAIF,IAAa,SAIfA,EADkC,QAAQ,cAAc,EACjC,SAElBD,EACLC,EAGAE,CACF,CACF,CAOA,SAASC,GAAiB,CACxB,OAAO,EAAAC,OACT,CAqBO,MAAMjB,GAA6B,IAAM,CAC9C,MAAMkB,EAAiC,CACrC,UAAW,IACb,EAEMC,EAAgD,CACpD,UAAW,IACb,EACMC,EAAO,IAAM,CACjB,MAAMC,KAAY,EAAAC,SAAmB,EAC/BC,EAASP,EAAe,KAC9B,gBAAaE,EAAQ,CACnB,KAAMK,EAAO,IAAIF,EAAY,SAAM,MAAG,EACtC,KAAME,EAAO,KAAKF,EAAY,SAAM,GAAG,EACvC,QAASE,EAAO,MAAMF,EAAY,SAAM,QAAG,EAC3C,KAAME,EAAO,OAAOF,EAAY,SAAM,QAAG,CAC3C,CAAC,KACD,gBAAaH,CAAM,EAGnB,UAAWM,KAAYL,EACrB,OAAOA,EAAQK,CAAsD,CAEzE,EACA,UAAWA,KAAY,QAAQ,QAAQ,OAAO,EAAG,CAC/C,MAAMC,EAAM,QAAyCD,CAAQ,EACzD,OAAOC,GAAO,aACdN,EACAK,CACF,EAAI,IAAIT,KACNK,EAAK,EACEK,EAAG,GAAGV,CAAI,GAGvB,CACA,OAAO,IAAI,MAAMG,EAAQC,CAAO,CAClC,GAAG,EAEGO,EAAsB,CAG1B,sBACA,sBAEA,SACA,QACA,QACA,aACA,aACA,QACA,MACA,SACA,QAOA,OACA,MACA,QACA,OACA,UACA,UACA,QACA,MACF,EACG,OAAOC,GAAK,OAAQjB,EAAsBiB,CAAC,GAAM,UAAU,EAC3D,IAAIA,GAAK,CAACA,EAAIjB,EAAsBiB,CAAC,EAAE,KAAKjB,CAAa,CAAC,CAAC,EAExDkB,EAAwB,CAC5B,UAAW,KACX,SAAU,GACV,WAAY,GACZ,aAAc,EAChB,EACMC,EAAiB,IACjBC,EAAiB,IAAI,QAErBC,EAAiB,OAAO,sBAAsBrB,CAAa,EAQpDR,EAAwB,OAAO,IAAI,uBAAuB,EAEjE8B,EACJD,EAAe,KAAKE,GAAMA,EAAU,QAAU,mBAAmB,GACjE,OAAO,mBAAmB,EAQf9B,EAAqB,OAAO,IAAI,qBAAqB,EA8D3D,MAAMF,CAAO,CASlB,OAAO,YAAcD,EAErBkC,GACAC,GACAC,GACAC,GACAC,GAAmB,GACnBC,GAAmB,GACnBC,
|
|
6
|
-
"names": ["logger_exports", "__export", "LOG_SYMBOLS", "Logger", "incLogCallCountSymbol", "lastWasBlankSymbol", "logger", "__toCommonJS", "import_is_unicode_supported", "import_yoctocolors_cjs", "import_objects", "import_strings", "globalConsole", "ReflectApply", "ReflectConstruct", "_Console", "constructConsole", "args", "getYoctocolors", "yoctocolorsCjs", "target", "handler", "init", "supported", "isUnicodeSupported", "colors", "trapName", "fn", "boundConsoleEntries", "n", "consolePropAttributes", "maxIndentation", "privateConsole", "consoleSymbols", "kGroupIndentationWidthSymbol", "s", "#parent", "#boundStream", "#stderrLogger", "#stdoutLogger", "#stderrIndention", "#stdoutIndention", "#
|
|
4
|
+
"sourcesContent": ["/**\n * @fileoverview Console logging utilities with line prefix support.\n * Provides enhanced console methods with formatted output capabilities.\n */\n\nimport isUnicodeSupported from './external/@socketregistry/is-unicode-supported'\nimport yoctocolorsCjs from './external/yoctocolors-cjs'\nimport { objectAssign, objectFreeze } from './objects'\nimport { applyLinePrefix, isBlankString } from './strings'\n\n/**\n * Log symbols for terminal output with colored indicators.\n *\n * Each symbol provides visual feedback for different message types, with\n * Unicode and ASCII fallback support.\n *\n * @example\n * ```typescript\n * import { LOG_SYMBOLS } from '@socketsecurity/lib'\n *\n * console.log(`${LOG_SYMBOLS.success} Operation completed`)\n * console.log(`${LOG_SYMBOLS.fail} Operation failed`)\n * console.log(`${LOG_SYMBOLS.warn} Warning message`)\n * console.log(`${LOG_SYMBOLS.info} Information message`)\n * ```\n */\ntype LogSymbols = {\n /** Red colored failure symbol (\u2716 or \u00D7 in ASCII) */\n fail: string\n /** Blue colored information symbol (\u2139 or i in ASCII) */\n info: string\n /** Green colored success symbol (\u2714 or \u221A in ASCII) */\n success: string\n /** Yellow colored warning symbol (\u26A0 or \u203C in ASCII) */\n warn: string\n}\n\n/**\n * Type definition for logger methods that mirror console methods.\n *\n * All methods return the logger instance for method chaining.\n */\ntype LoggerMethods = {\n [K in keyof typeof console]: (typeof console)[K] extends (\n ...args: infer A\n ) => any\n ? (...args: A) => Logger\n : (typeof console)[K]\n}\n\n/**\n * A task that can be executed with automatic start/complete logging.\n *\n * @example\n * ```typescript\n * const task = logger.createTask('Database migration')\n * task.run(() => {\n * // Migration logic here\n * })\n * // Logs: \"Starting task: Database migration\"\n * // Logs: \"Completed task: Database migration\"\n * ```\n */\ninterface Task {\n /**\n * Executes the task function with automatic logging.\n *\n * @template T - The return type of the task function\n * @param f - The function to execute\n * @returns The result of the task function\n */\n run<T>(f: () => T): T\n}\n\nexport type { LogSymbols, LoggerMethods, Task }\n\nconst globalConsole = console\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\nconst ReflectConstruct = Reflect.construct\n\nlet _Console: typeof import('console').Console | undefined\n/**\n * Construct a new Console instance.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction constructConsole(...args: unknown[]) {\n if (_Console === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n const nodeConsole = /*@__PURE__*/ require('node:console')\n _Console = nodeConsole.Console\n }\n return ReflectConstruct(\n _Console! as new (\n ...args: unknown[]\n ) => Console, // eslint-disable-line no-undef\n args,\n )\n}\n\n/**\n * Get the yoctocolors module for terminal colors.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getYoctocolors() {\n return yoctocolorsCjs\n}\n\n/**\n * Log symbols for terminal output with colored indicators.\n *\n * Provides colored Unicode symbols (\u2714, \u2716, \u26A0, \u2139) with ASCII fallbacks (\u221A, \u00D7, \u203C, i)\n * for terminals that don't support Unicode. Symbols are color-coded: green for\n * success, red for failure, yellow for warnings, blue for info.\n *\n * The symbols are lazily initialized on first access and then frozen for immutability.\n *\n * @example\n * ```typescript\n * import { LOG_SYMBOLS } from '@socketsecurity/lib'\n *\n * console.log(`${LOG_SYMBOLS.success} Build completed`) // Green \u2714\n * console.log(`${LOG_SYMBOLS.fail} Build failed`) // Red \u2716\n * console.log(`${LOG_SYMBOLS.warn} Deprecated API used`) // Yellow \u26A0\n * console.log(`${LOG_SYMBOLS.info} Starting process`) // Blue \u2139\n * ```\n */\nexport const LOG_SYMBOLS = /*@__PURE__*/ (() => {\n const target: Record<string, string> = {\n __proto__: null,\n } as unknown as Record<string, string>\n // Mutable handler to simulate a frozen target.\n const handler: ProxyHandler<Record<string, string>> = {\n __proto__: null,\n } as unknown as ProxyHandler<Record<string, string>>\n const init = () => {\n const supported = isUnicodeSupported()\n const colors = getYoctocolors()\n objectAssign(target, {\n fail: colors.red(supported ? '\u2716' : '\u00D7'),\n info: colors.blue(supported ? '\u2139' : 'i'),\n success: colors.green(supported ? '\u2714' : '\u221A'),\n warn: colors.yellow(supported ? '\u26A0' : '\u203C'),\n })\n objectFreeze(target)\n // The handler of a Proxy is mutable after proxy instantiation.\n // We delete the traps to defer to native behavior.\n for (const trapName in handler) {\n delete handler[trapName as keyof ProxyHandler<Record<string, string>>]\n }\n }\n for (const trapName of Reflect.ownKeys(Reflect)) {\n const fn = (Reflect as Record<PropertyKey, unknown>)[trapName]\n if (typeof fn === 'function') {\n ;(handler as Record<string, (...args: unknown[]) => unknown>)[\n trapName as string\n ] = (...args: unknown[]) => {\n init()\n return fn(...args)\n }\n }\n }\n return new Proxy(target, handler)\n})()\n\nconst boundConsoleEntries = [\n // Add bound properties from console[kBindProperties](ignoreErrors, colorMode, groupIndentation).\n // https://github.com/nodejs/node/blob/v24.0.1/lib/internal/console/constructor.js#L230-L265\n '_stderrErrorHandler',\n '_stdoutErrorHandler',\n // Add methods that need to be bound to function properly.\n 'assert',\n 'clear',\n 'count',\n 'countReset',\n 'createTask',\n 'debug',\n 'dir',\n 'dirxml',\n 'error',\n // Skip group methods because in at least Node 20 with the Node --frozen-intrinsics\n // flag it triggers a readonly property for Symbol(kGroupIndent). Instead, we\n // implement these methods ourselves.\n //'group',\n //'groupCollapsed',\n //'groupEnd',\n 'info',\n 'log',\n 'table',\n 'time',\n 'timeEnd',\n 'timeLog',\n 'trace',\n 'warn',\n]\n .filter(n => typeof (globalConsole as any)[n] === 'function')\n .map(n => [n, (globalConsole as any)[n].bind(globalConsole)])\n\nconst consolePropAttributes = {\n __proto__: null,\n writable: true,\n enumerable: false,\n configurable: true,\n}\nconst maxIndentation = 1000\nconst privateConsole = new WeakMap()\n\nconst consoleSymbols = Object.getOwnPropertySymbols(globalConsole)\n\n/**\n * Symbol for incrementing the internal log call counter.\n *\n * This is an internal symbol used to track the number of times logging\n * methods have been called on a logger instance.\n */\nexport const incLogCallCountSymbol = Symbol.for('logger.logCallCount++')\n\nconst kGroupIndentationWidthSymbol =\n consoleSymbols.find(s => (s as any).label === 'kGroupIndentWidth') ??\n Symbol('kGroupIndentWidth')\n\n/**\n * Symbol for tracking whether the last logged line was blank.\n *\n * This is used internally to prevent multiple consecutive blank lines\n * and to determine whether to add spacing before certain messages.\n */\nexport const lastWasBlankSymbol = Symbol.for('logger.lastWasBlank')\n\n/**\n * Enhanced console logger with indentation, colored symbols, and stream management.\n *\n * Provides a fluent API for logging with automatic indentation tracking, colored\n * status symbols, separate stderr/stdout management, and method chaining. All\n * methods return `this` for easy chaining.\n *\n * Features:\n * - Automatic line prefixing with indentation\n * - Colored status symbols (success, fail, warn, info)\n * - Separate indentation tracking for stderr and stdout\n * - Stream-bound logger instances via `.stderr` and `.stdout`\n * - Group/indentation management\n * - Progress indicators with clearable lines\n * - Task execution with automatic logging\n *\n * @example\n * ```typescript\n * import { logger } from '@socketsecurity/lib'\n *\n * // Basic logging with symbols\n * logger.success('Build completed')\n * logger.fail('Build failed')\n * logger.warn('Deprecated API')\n * logger.info('Starting process')\n *\n * // Indentation and grouping\n * logger.log('Processing files:')\n * logger.indent()\n * logger.log('file1.js')\n * logger.log('file2.js')\n * logger.dedent()\n *\n * // Method chaining\n * logger\n * .log('Step 1')\n * .indent()\n * .log('Substep 1.1')\n * .log('Substep 1.2')\n * .dedent()\n * .log('Step 2')\n *\n * // Stream-specific logging\n * logger.stdout.log('Normal output')\n * logger.stderr.error('Error message')\n *\n * // Progress indicators\n * logger.progress('Processing...')\n * // ... do work ...\n * logger.clearLine()\n * logger.success('Done')\n *\n * // Task execution\n * const task = logger.createTask('Migration')\n * task.run(() => {\n * // Migration logic\n * })\n * ```\n */\n/*@__PURE__*/\nexport class Logger {\n /**\n * Static reference to log symbols for convenience.\n *\n * @example\n * ```typescript\n * console.log(`${Logger.LOG_SYMBOLS.success} Done`)\n * ```\n */\n static LOG_SYMBOLS = LOG_SYMBOLS\n\n #parent?: Logger\n #boundStream?: 'stderr' | 'stdout'\n #stderrLogger?: Logger\n #stdoutLogger?: Logger\n #stderrIndention = ''\n #stdoutIndention = ''\n #stderrLastWasBlank = false\n #stdoutLastWasBlank = false\n #logCallCount = 0\n #constructorArgs: unknown[]\n #options: Record<string, unknown>\n\n /**\n * Creates a new Logger instance.\n *\n * When called without arguments, creates a logger using the default\n * `process.stdout` and `process.stderr` streams. Can accept custom\n * console constructor arguments for advanced use cases.\n *\n * @param args - Optional console constructor arguments\n *\n * @example\n * ```typescript\n * // Default logger\n * const logger = new Logger()\n *\n * // Custom streams (advanced)\n * const customLogger = new Logger({\n * stdout: customWritableStream,\n * stderr: customErrorStream\n * })\n * ```\n */\n constructor(...args: unknown[]) {\n // Store constructor args for child loggers\n this.#constructorArgs = args\n\n // Store options if provided (for future extensibility)\n const options = args['0']\n if (typeof options === 'object' && options !== null) {\n this.#options = { __proto__: null, ...options }\n } else {\n this.#options = { __proto__: null }\n }\n\n if (args.length) {\n privateConsole.set(this, constructConsole(...args))\n } else {\n // Create a new console that acts like the builtin one so that it will\n // work with Node's --frozen-intrinsics flag.\n const con = constructConsole({\n stdout: process.stdout,\n stderr: process.stderr,\n }) as typeof console & Record<string, unknown>\n for (const { 0: key, 1: method } of boundConsoleEntries) {\n con[key] = method\n }\n privateConsole.set(this, con)\n }\n }\n\n /**\n * Gets a logger instance bound exclusively to stderr.\n *\n * All logging operations on this instance will write to stderr only.\n * Indentation is tracked separately from stdout. The instance is\n * cached and reused on subsequent accesses.\n *\n * @returns A logger instance bound to stderr\n *\n * @example\n * ```typescript\n * // Write errors to stderr\n * logger.stderr.error('Configuration invalid')\n * logger.stderr.warn('Using fallback settings')\n *\n * // Indent only affects stderr\n * logger.stderr.indent()\n * logger.stderr.error('Nested error details')\n * logger.stderr.dedent()\n * ```\n */\n get stderr(): Logger {\n if (!this.#stderrLogger) {\n // Pass parent's constructor args to maintain config\n const instance = new Logger(...this.#constructorArgs)\n instance.#parent = this\n instance.#boundStream = 'stderr'\n instance.#options = { __proto__: null, ...this.#options }\n this.#stderrLogger = instance\n }\n return this.#stderrLogger\n }\n\n /**\n * Gets a logger instance bound exclusively to stdout.\n *\n * All logging operations on this instance will write to stdout only.\n * Indentation is tracked separately from stderr. The instance is\n * cached and reused on subsequent accesses.\n *\n * @returns A logger instance bound to stdout\n *\n * @example\n * ```typescript\n * // Write normal output to stdout\n * logger.stdout.log('Processing started')\n * logger.stdout.log('Items processed: 42')\n *\n * // Indent only affects stdout\n * logger.stdout.indent()\n * logger.stdout.log('Detailed output')\n * logger.stdout.dedent()\n * ```\n */\n get stdout(): Logger {\n if (!this.#stdoutLogger) {\n // Pass parent's constructor args to maintain config\n const instance = new Logger(...this.#constructorArgs)\n instance.#parent = this\n instance.#boundStream = 'stdout'\n instance.#options = { __proto__: null, ...this.#options }\n this.#stdoutLogger = instance\n }\n return this.#stdoutLogger\n }\n\n /**\n * Get the root logger (for accessing shared indentation state).\n * @private\n */\n #getRoot(): Logger {\n return this.#parent || this\n }\n\n /**\n * Get indentation for a specific stream.\n * @private\n */\n #getIndent(stream: 'stderr' | 'stdout'): string {\n const root = this.#getRoot()\n return stream === 'stderr' ? root.#stderrIndention : root.#stdoutIndention\n }\n\n /**\n * Set indentation for a specific stream.\n * @private\n */\n #setIndent(stream: 'stderr' | 'stdout', value: string): void {\n const root = this.#getRoot()\n if (stream === 'stderr') {\n root.#stderrIndention = value\n } else {\n root.#stdoutIndention = value\n }\n }\n\n /**\n * Get lastWasBlank state for a specific stream.\n * @private\n */\n #getLastWasBlank(stream: 'stderr' | 'stdout'): boolean {\n const root = this.#getRoot()\n return stream === 'stderr'\n ? root.#stderrLastWasBlank\n : root.#stdoutLastWasBlank\n }\n\n /**\n * Set lastWasBlank state for a specific stream.\n * @private\n */\n #setLastWasBlank(stream: 'stderr' | 'stdout', value: boolean): void {\n const root = this.#getRoot()\n if (stream === 'stderr') {\n root.#stderrLastWasBlank = value\n } else {\n root.#stdoutLastWasBlank = value\n }\n }\n\n /**\n * Get the target stream for this logger instance.\n * @private\n */\n #getTargetStream(): 'stderr' | 'stdout' {\n return this.#boundStream || 'stderr'\n }\n\n /**\n * Apply a console method with indentation.\n * @private\n */\n #apply(\n methodName: string,\n args: unknown[],\n stream?: 'stderr' | 'stdout',\n ): this {\n const con = privateConsole.get(this) as typeof console &\n Record<string, unknown>\n const text = args.at(0)\n const hasText = typeof text === 'string'\n // Determine which stream this method writes to\n const targetStream = stream || (methodName === 'log' ? 'stdout' : 'stderr')\n const indent = this.#getIndent(targetStream)\n const logArgs = hasText\n ? [applyLinePrefix(text, { prefix: indent }), ...args.slice(1)]\n : args\n ReflectApply(\n con[methodName] as (...args: unknown[]) => unknown,\n con,\n logArgs,\n )\n this[lastWasBlankSymbol](hasText && isBlankString(logArgs[0]), targetStream)\n ;(this as any)[incLogCallCountSymbol]()\n return this\n }\n\n /**\n * Strip log symbols from the start of text.\n * @private\n */\n #stripSymbols(text: string): string {\n // Strip both unicode and emoji forms of log symbols from the start.\n // Matches: \u2716, \u2717, \u00D7, \u2716\uFE0F, \u26A0, \u203C, \u26A0\uFE0F, \u2714, \u2713, \u221A, \u2714\uFE0F, \u2713\uFE0F, \u2139, \u2139\uFE0F\n // Also handles variation selectors (U+FE0F) and whitespace after symbol.\n // Note: We don't strip standalone 'i' to avoid breaking words like 'info'.\n return text.replace(/^[\u2716\u2717\u00D7\u26A0\u203C\u2714\u2713\u221A\u2139]\\uFE0F?\\s*/u, '')\n }\n\n /**\n * Apply a method with a symbol prefix.\n * @private\n */\n #symbolApply(symbolType: string, args: unknown[]): this {\n const con = privateConsole.get(this)\n let text = args.at(0)\n // biome-ignore lint/suspicious/noImplicitAnyLet: Flexible argument handling.\n let extras\n if (typeof text === 'string') {\n text = this.#stripSymbols(text)\n extras = args.slice(1)\n } else {\n extras = args\n text = ''\n }\n // Note: Meta status messages (info/fail/etc) always go to stderr.\n const indent = this.#getIndent('stderr')\n con.error(\n applyLinePrefix(`${LOG_SYMBOLS[symbolType]} ${text}`, {\n prefix: indent,\n }),\n ...extras,\n )\n this[lastWasBlankSymbol](false, 'stderr')\n ;(this as any)[incLogCallCountSymbol]()\n return this\n }\n\n /**\n * Gets the total number of log calls made on this logger instance.\n *\n * Tracks all logging method calls including `log()`, `error()`, `warn()`,\n * `success()`, `fail()`, etc. Useful for testing and monitoring logging activity.\n *\n * @returns The number of times logging methods have been called\n *\n * @example\n * ```typescript\n * logger.log('Message 1')\n * logger.error('Message 2')\n * console.log(logger.logCallCount) // 2\n * ```\n */\n get logCallCount() {\n const root = this.#getRoot()\n return root.#logCallCount\n }\n\n /**\n * Increments the internal log call counter.\n *\n * This is called automatically by logging methods and should not\n * be called directly in normal usage.\n *\n * @returns The logger instance for chaining\n */\n [incLogCallCountSymbol]() {\n const root = this.#getRoot()\n root.#logCallCount += 1\n return this\n }\n\n /**\n * Sets whether the last logged line was blank.\n *\n * Used internally to track blank lines and prevent duplicate spacing.\n * This is called automatically by logging methods.\n *\n * @param value - Whether the last line was blank\n * @param stream - Optional stream to update (defaults to both streams if not bound, or target stream if bound)\n * @returns The logger instance for chaining\n */\n [lastWasBlankSymbol](value: unknown, stream?: 'stderr' | 'stdout'): this {\n if (stream) {\n // Explicit stream specified\n this.#setLastWasBlank(stream, !!value)\n } else if (this.#boundStream) {\n // Stream-bound logger - affect only the bound stream\n this.#setLastWasBlank(this.#boundStream, !!value)\n } else {\n // Root logger with no stream specified - affect both streams\n this.#setLastWasBlank('stderr', !!value)\n this.#setLastWasBlank('stdout', !!value)\n }\n return this\n }\n\n /**\n * Logs an assertion failure message if the value is falsy.\n *\n * Works like `console.assert()` but returns the logger for chaining.\n * If the value is truthy, nothing is logged. If falsy, logs an error\n * message with an assertion failure.\n *\n * @param value - The value to test\n * @param message - Optional message and additional arguments to log\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.assert(true, 'This will not log')\n * logger.assert(false, 'Assertion failed: value is false')\n * logger.assert(items.length > 0, 'No items found')\n * ```\n */\n assert(value: unknown, ...message: unknown[]): this {\n const con = privateConsole.get(this)\n con.assert(value, ...message)\n this[lastWasBlankSymbol](false)\n return value ? this : this[incLogCallCountSymbol]()\n }\n\n /**\n * Clears the visible terminal screen.\n *\n * Only available on the main logger instance, not on stream-bound instances\n * (`.stderr` or `.stdout`). Resets the log call count and blank line tracking\n * if the output is a TTY.\n *\n * @returns The logger instance for chaining\n * @throws {Error} If called on a stream-bound logger instance\n *\n * @example\n * ```typescript\n * logger.log('Some output')\n * logger.clearVisible() // Screen is now clear\n *\n * // Error: Can't call on stream-bound instance\n * logger.stderr.clearVisible() // throws\n * ```\n */\n clearVisible() {\n if (this.#boundStream) {\n throw new Error(\n 'clearVisible() is only available on the main logger instance, not on stream-bound instances',\n )\n }\n const con = privateConsole.get(this)\n con.clear()\n if ((con as any)._stdout.isTTY) {\n ;(this as any)[lastWasBlankSymbol](true)\n this.#logCallCount = 0\n }\n return this\n }\n\n /**\n * Increments and logs a counter for the given label.\n *\n * Each unique label maintains its own counter. Works like `console.count()`.\n *\n * @param label - Optional label for the counter\n * @default 'default'\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.count('requests') // requests: 1\n * logger.count('requests') // requests: 2\n * logger.count('errors') // errors: 1\n * logger.count() // default: 1\n * ```\n */\n count(label?: string | undefined): this {\n const con = privateConsole.get(this)\n con.count(label)\n this[lastWasBlankSymbol](false)\n return this[incLogCallCountSymbol]()\n }\n\n /**\n * Creates a task that logs start and completion messages automatically.\n *\n * Returns a task object with a `run()` method that executes the provided\n * function and logs \"Starting task: {name}\" before execution and\n * \"Completed task: {name}\" after completion.\n *\n * @param name - The name of the task\n * @returns A task object with a `run()` method\n *\n * @example\n * ```typescript\n * const task = logger.createTask('Database Migration')\n * const result = task.run(() => {\n * // Logs: \"Starting task: Database Migration\"\n * migrateDatabase()\n * return 'success'\n * // Logs: \"Completed task: Database Migration\"\n * })\n * console.log(result) // 'success'\n * ```\n */\n createTask(name: string): Task {\n return {\n run: <T>(f: () => T): T => {\n this.log(`Starting task: ${name}`)\n const result = f()\n this.log(`Completed task: ${name}`)\n return result\n },\n }\n }\n\n /**\n * Decreases the indentation level by removing spaces from the prefix.\n *\n * When called on the main logger, affects both stderr and stdout indentation.\n * When called on a stream-bound logger (`.stderr` or `.stdout`), affects\n * only that stream's indentation.\n *\n * @param spaces - Number of spaces to remove from indentation\n * @default 2\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.indent()\n * logger.log('Indented')\n * logger.dedent()\n * logger.log('Back to normal')\n *\n * // Remove custom amount\n * logger.indent(4)\n * logger.log('Four spaces')\n * logger.dedent(4)\n *\n * // Stream-specific dedent\n * logger.stdout.indent()\n * logger.stdout.log('Indented stdout')\n * logger.stdout.dedent()\n * ```\n */\n dedent(spaces = 2) {\n if (this.#boundStream) {\n // Only affect bound stream\n const current = this.#getIndent(this.#boundStream)\n this.#setIndent(this.#boundStream, current.slice(0, -spaces))\n } else {\n // Affect both streams\n const stderrCurrent = this.#getIndent('stderr')\n const stdoutCurrent = this.#getIndent('stdout')\n this.#setIndent('stderr', stderrCurrent.slice(0, -spaces))\n this.#setIndent('stdout', stdoutCurrent.slice(0, -spaces))\n }\n return this\n }\n\n /**\n * Displays an object's properties in a formatted way.\n *\n * Works like `console.dir()` with customizable options for depth,\n * colors, etc. Useful for inspecting complex objects.\n *\n * @param obj - The object to display\n * @param options - Optional formatting options (Node.js inspect options)\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * const obj = { a: 1, b: { c: 2, d: { e: 3 } } }\n * logger.dir(obj)\n * logger.dir(obj, { depth: 1 }) // Limit nesting depth\n * logger.dir(obj, { colors: true }) // Enable colors\n * ```\n */\n dir(obj: unknown, options?: unknown | undefined): this {\n const con = privateConsole.get(this)\n con.dir(obj, options)\n this[lastWasBlankSymbol](false)\n return this[incLogCallCountSymbol]()\n }\n\n /**\n * Displays data as XML/HTML in a formatted way.\n *\n * Works like `console.dirxml()`. In Node.js, behaves the same as `dir()`.\n *\n * @param data - The data to display\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.dirxml(document.body) // In browser environments\n * logger.dirxml(xmlObject) // In Node.js\n * ```\n */\n dirxml(...data: unknown[]): this {\n const con = privateConsole.get(this)\n con.dirxml(data)\n this[lastWasBlankSymbol](false)\n return this[incLogCallCountSymbol]()\n }\n\n /**\n * Logs an error message to stderr.\n *\n * Automatically applies current indentation. All arguments are formatted\n * and logged like `console.error()`.\n *\n * @param args - Message and additional arguments to log\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.error('Build failed')\n * logger.error('Error code:', 500)\n * logger.error('Details:', { message: 'Not found' })\n * ```\n */\n error(...args: unknown[]): this {\n return this.#apply('error', args)\n }\n\n /**\n * Logs a newline to stderr only if the last line wasn't already blank.\n *\n * Prevents multiple consecutive blank lines. Useful for adding spacing\n * between sections without creating excessive whitespace.\n *\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.error('Error message')\n * logger.errorNewline() // Adds blank line\n * logger.errorNewline() // Does nothing (already blank)\n * logger.error('Next section')\n * ```\n */\n errorNewline() {\n return this.#getLastWasBlank('stderr') ? this : this.error('')\n }\n\n /**\n * Logs a failure message with a red colored fail symbol.\n *\n * Automatically prefixes the message with `LOG_SYMBOLS.fail` (red \u2716).\n * Always outputs to stderr. If the message starts with an existing\n * symbol, it will be stripped and replaced.\n *\n * @param args - Message and additional arguments to log\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.fail('Build failed')\n * logger.fail('Test suite failed:', { passed: 5, failed: 3 })\n * ```\n */\n fail(...args: unknown[]): this {\n return this.#symbolApply('fail', args)\n }\n\n /**\n * Starts a new indented log group.\n *\n * If a label is provided, it's logged before increasing indentation.\n * Groups can be nested. Each group increases indentation by the\n * `kGroupIndentWidth` (default 2 spaces). Call `groupEnd()` to close.\n *\n * @param label - Optional label to display before the group\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.group('Processing files:')\n * logger.log('file1.js')\n * logger.log('file2.js')\n * logger.groupEnd()\n *\n * // Nested groups\n * logger.group('Outer')\n * logger.log('Outer content')\n * logger.group('Inner')\n * logger.log('Inner content')\n * logger.groupEnd()\n * logger.groupEnd()\n * ```\n */\n group(...label: unknown[]): this {\n const { length } = label\n if (length) {\n ReflectApply(this.log, this, label)\n }\n this.indent((this as any)[kGroupIndentationWidthSymbol])\n if (length) {\n ;(this as any)[lastWasBlankSymbol](false)\n ;(this as any)[incLogCallCountSymbol]()\n }\n return this\n }\n\n /**\n * Starts a new collapsed log group (alias for `group()`).\n *\n * In browser consoles, this creates a collapsed group. In Node.js,\n * it behaves identically to `group()`.\n *\n * @param label - Optional label to display before the group\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.groupCollapsed('Details')\n * logger.log('Hidden by default in browsers')\n * logger.groupEnd()\n * ```\n */\n // groupCollapsed is an alias of group.\n // https://nodejs.org/api/console.html#consolegroupcollapsed\n groupCollapsed(...label: unknown[]): this {\n return ReflectApply(this.group, this, label)\n }\n\n /**\n * Ends the current log group and decreases indentation.\n *\n * Must be called once for each `group()` or `groupCollapsed()` call\n * to properly close the group and restore indentation.\n *\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.group('Group 1')\n * logger.log('Content')\n * logger.groupEnd() // Closes 'Group 1'\n * ```\n */\n groupEnd() {\n this.dedent((this as any)[kGroupIndentationWidthSymbol])\n return this\n }\n\n /**\n * Increases the indentation level by adding spaces to the prefix.\n *\n * When called on the main logger, affects both stderr and stdout indentation.\n * When called on a stream-bound logger (`.stderr` or `.stdout`), affects\n * only that stream's indentation. Maximum indentation is 1000 spaces.\n *\n * @param spaces - Number of spaces to add to indentation\n * @default 2\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.log('Level 0')\n * logger.indent()\n * logger.log('Level 1')\n * logger.indent()\n * logger.log('Level 2')\n * logger.dedent()\n * logger.dedent()\n *\n * // Custom indent amount\n * logger.indent(4)\n * logger.log('Indented 4 spaces')\n * logger.dedent(4)\n *\n * // Stream-specific indent\n * logger.stdout.indent()\n * logger.stdout.log('Only stdout is indented')\n * ```\n */\n indent(spaces = 2) {\n const spacesToAdd = ' '.repeat(Math.min(spaces, maxIndentation))\n if (this.#boundStream) {\n // Only affect bound stream\n const current = this.#getIndent(this.#boundStream)\n this.#setIndent(this.#boundStream, current + spacesToAdd)\n } else {\n // Affect both streams\n const stderrCurrent = this.#getIndent('stderr')\n const stdoutCurrent = this.#getIndent('stdout')\n this.#setIndent('stderr', stderrCurrent + spacesToAdd)\n this.#setIndent('stdout', stdoutCurrent + spacesToAdd)\n }\n return this\n }\n\n /**\n * Logs an informational message with a blue colored info symbol.\n *\n * Automatically prefixes the message with `LOG_SYMBOLS.info` (blue \u2139).\n * Always outputs to stderr. If the message starts with an existing\n * symbol, it will be stripped and replaced.\n *\n * @param args - Message and additional arguments to log\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.info('Starting build process')\n * logger.info('Configuration loaded:', config)\n * logger.info('Using cache directory:', cacheDir)\n * ```\n */\n info(...args: unknown[]): this {\n return this.#symbolApply('info', args)\n }\n\n /**\n * Logs a message to stdout.\n *\n * Automatically applies current indentation. All arguments are formatted\n * and logged like `console.log()`. This is the primary method for\n * standard output.\n *\n * @param args - Message and additional arguments to log\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.log('Processing complete')\n * logger.log('Items processed:', 42)\n * logger.log('Results:', { success: true, count: 10 })\n *\n * // Method chaining\n * logger.log('Step 1').log('Step 2').log('Step 3')\n * ```\n */\n log(...args: unknown[]): this {\n return this.#apply('log', args)\n }\n\n /**\n * Logs a newline to stdout only if the last line wasn't already blank.\n *\n * Prevents multiple consecutive blank lines. Useful for adding spacing\n * between sections without creating excessive whitespace.\n *\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.log('Section 1')\n * logger.logNewline() // Adds blank line\n * logger.logNewline() // Does nothing (already blank)\n * logger.log('Section 2')\n * ```\n */\n logNewline() {\n return this.#getLastWasBlank('stdout') ? this : this.log('')\n }\n\n /**\n * Resets all indentation to zero.\n *\n * When called on the main logger, resets both stderr and stdout indentation.\n * When called on a stream-bound logger (`.stderr` or `.stdout`), resets\n * only that stream's indentation.\n *\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.indent().indent().indent()\n * logger.log('Very indented')\n * logger.resetIndent()\n * logger.log('Back to zero indentation')\n *\n * // Reset only stdout\n * logger.stdout.resetIndent()\n * ```\n */\n resetIndent() {\n if (this.#boundStream) {\n // Only reset bound stream\n this.#setIndent(this.#boundStream, '')\n } else {\n // Reset both streams\n this.#setIndent('stderr', '')\n this.#setIndent('stdout', '')\n }\n return this\n }\n\n /**\n * Logs a main step message with a blank line before it (stateless).\n *\n * Automatically adds a blank line before the message unless the last\n * line was already blank. Useful for marking major steps in a process\n * with clear visual separation.\n *\n * @param msg - The step message to log\n * @param extras - Additional arguments to log\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.step('Building project')\n * logger.log('Compiling TypeScript...')\n * logger.step('Running tests')\n * logger.log('Running test suite...')\n * // Output:\n * // [blank line]\n * // Building project\n * // Compiling TypeScript...\n * // [blank line]\n * // Running tests\n * // Running test suite...\n * ```\n */\n step(msg: string, ...extras: unknown[]): this {\n // Add blank line before the step message.\n if (!this.#getLastWasBlank('stdout')) {\n // Use this.log() to properly track the blank line.\n this.log('')\n }\n // Let log() handle all tracking.\n return this.log(msg, ...extras)\n }\n\n /**\n * Logs an indented substep message (stateless).\n *\n * Adds a 2-space indent to the message without affecting the logger's\n * indentation state. Useful for showing sub-items under a main step.\n *\n * @param msg - The substep message to log\n * @param extras - Additional arguments to log\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.log('Installing dependencies:')\n * logger.substep('Installing react')\n * logger.substep('Installing typescript')\n * logger.substep('Installing eslint')\n * // Output:\n * // Installing dependencies:\n * // Installing react\n * // Installing typescript\n * // Installing eslint\n * ```\n */\n substep(msg: string, ...extras: unknown[]): this {\n // Add 2-space indent to the message.\n const indentedMsg = ` ${msg}`\n // Let log() handle all tracking.\n return this.log(indentedMsg, ...extras)\n }\n\n /**\n * Logs a success message with a green colored success symbol.\n *\n * Automatically prefixes the message with `LOG_SYMBOLS.success` (green \u2714).\n * Always outputs to stderr. If the message starts with an existing\n * symbol, it will be stripped and replaced.\n *\n * @param args - Message and additional arguments to log\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.success('Build completed')\n * logger.success('Tests passed:', { total: 42, passed: 42 })\n * logger.success('Deployment successful')\n * ```\n */\n success(...args: unknown[]): this {\n return this.#symbolApply('success', args)\n }\n\n /**\n * Logs a completion message with a success symbol (alias for `success()`).\n *\n * Provides semantic clarity when marking something as \"done\". Does NOT\n * automatically clear the current line - call `clearLine()` first if\n * needed after using `progress()`.\n *\n * @param args - Message and additional arguments to log\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.done('Task completed')\n *\n * // After progress indicator\n * logger.progress('Processing...')\n * // ... do work ...\n * logger.clearLine()\n * logger.done('Processing complete')\n * ```\n */\n done(...args: unknown[]): this {\n return this.#symbolApply('success', args)\n }\n\n /**\n * Displays data in a table format.\n *\n * Works like `console.table()`. Accepts arrays of objects or\n * objects with nested objects. Optionally specify which properties\n * to include in the table.\n *\n * @param tabularData - The data to display as a table\n * @param properties - Optional array of property names to include\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * // Array of objects\n * logger.table([\n * { name: 'Alice', age: 30 },\n * { name: 'Bob', age: 25 }\n * ])\n *\n * // Specify properties to show\n * logger.table(users, ['name', 'email'])\n *\n * // Object with nested objects\n * logger.table({\n * user1: { name: 'Alice', age: 30 },\n * user2: { name: 'Bob', age: 25 }\n * })\n * ```\n */\n table(\n tabularData: unknown,\n properties?: readonly string[] | undefined,\n ): this {\n const con = privateConsole.get(this)\n con.table(tabularData, properties)\n this[lastWasBlankSymbol](false)\n return this[incLogCallCountSymbol]()\n }\n\n /**\n * Ends a timer and logs the elapsed time.\n *\n * Logs the duration since `console.time()` was called with the same\n * label. The timer is stopped and removed.\n *\n * @param label - Optional label for the timer\n * @default 'default'\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * console.time('operation')\n * // ... do work ...\n * logger.timeEnd('operation')\n * // Logs: \"operation: 123.456ms\"\n *\n * console.time()\n * // ... do work ...\n * logger.timeEnd()\n * // Logs: \"default: 123.456ms\"\n * ```\n */\n timeEnd(label?: string | undefined): this {\n const con = privateConsole.get(this)\n con.timeEnd(label)\n this[lastWasBlankSymbol](false)\n return this[incLogCallCountSymbol]()\n }\n\n /**\n * Logs the current value of a timer without stopping it.\n *\n * Logs the duration since `console.time()` was called with the same\n * label, but keeps the timer running. Can include additional data\n * to log alongside the time.\n *\n * @param label - Optional label for the timer\n * @param data - Additional data to log with the time\n * @default 'default'\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * console.time('process')\n * // ... partial work ...\n * logger.timeLog('process', 'Checkpoint 1')\n * // Logs: \"process: 123.456ms Checkpoint 1\"\n * // ... more work ...\n * logger.timeLog('process', 'Checkpoint 2')\n * // Logs: \"process: 234.567ms Checkpoint 2\"\n * console.timeEnd('process')\n * ```\n */\n timeLog(label?: string | undefined, ...data: unknown[]): this {\n const con = privateConsole.get(this)\n con.timeLog(label, ...data)\n this[lastWasBlankSymbol](false)\n return this[incLogCallCountSymbol]()\n }\n\n /**\n * Logs a stack trace to the console.\n *\n * Works like `console.trace()`. Shows the call stack leading to\n * where this method was called. Useful for debugging.\n *\n * @param message - Optional message to display with the trace\n * @param args - Additional arguments to log\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * function debugFunction() {\n * logger.trace('Debug point reached')\n * }\n *\n * logger.trace('Trace from here')\n * logger.trace('Error context:', { userId: 123 })\n * ```\n */\n trace(message?: unknown | undefined, ...args: unknown[]): this {\n const con = privateConsole.get(this)\n con.trace(message, ...args)\n this[lastWasBlankSymbol](false)\n return this[incLogCallCountSymbol]()\n }\n\n /**\n * Logs a warning message with a yellow colored warning symbol.\n *\n * Automatically prefixes the message with `LOG_SYMBOLS.warn` (yellow \u26A0).\n * Always outputs to stderr. If the message starts with an existing\n * symbol, it will be stripped and replaced.\n *\n * @param args - Message and additional arguments to log\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.warn('Deprecated API used')\n * logger.warn('Low memory:', { available: '100MB' })\n * logger.warn('Missing optional configuration')\n * ```\n */\n warn(...args: unknown[]): this {\n return this.#symbolApply('warn', args)\n }\n\n /**\n * Writes text directly to stdout without a newline or indentation.\n *\n * Useful for progress indicators or custom formatting where you need\n * low-level control. Does not apply any indentation or formatting.\n *\n * @param text - The text to write\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.write('Processing... ')\n * // ... do work ...\n * logger.write('done\\n')\n *\n * // Build a line incrementally\n * logger.write('Step 1')\n * logger.write('... Step 2')\n * logger.write('... Step 3\\n')\n * ```\n */\n write(text: string): this {\n const con = privateConsole.get(this)\n con._stdout.write(text)\n this[lastWasBlankSymbol](false)\n return this\n }\n\n /**\n * Shows a progress indicator that can be cleared with `clearLine()`.\n *\n * Displays a simple status message with a '\u2234' prefix. Does not include\n * animation or spinner. Intended to be cleared once the operation completes.\n * The output stream (stderr or stdout) depends on whether the logger is\n * stream-bound.\n *\n * @param text - The progress message to display\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.progress('Processing files...')\n * // ... do work ...\n * logger.clearLine()\n * logger.success('Files processed')\n *\n * // Stream-specific progress\n * logger.stdout.progress('Loading...')\n * // ... do work ...\n * logger.stdout.clearLine()\n * logger.stdout.log('Done')\n * ```\n */\n progress(text: string): this {\n const con = privateConsole.get(this)\n const stream = this.#getTargetStream()\n const streamObj = stream === 'stderr' ? con._stderr : con._stdout\n streamObj.write(`\u2234 ${text}`)\n this[lastWasBlankSymbol](false)\n return this\n }\n\n /**\n * Clears the current line in the terminal.\n *\n * Moves the cursor to the beginning of the line and clears all content.\n * Works in both TTY and non-TTY environments. Useful for clearing\n * progress indicators created with `progress()`.\n *\n * The stream to clear (stderr or stdout) depends on whether the logger\n * is stream-bound.\n *\n * @returns The logger instance for chaining\n *\n * @example\n * ```typescript\n * logger.progress('Loading...')\n * // ... do work ...\n * logger.clearLine()\n * logger.success('Loaded')\n *\n * // Clear multiple progress updates\n * for (const file of files) {\n * logger.progress(`Processing ${file}`)\n * processFile(file)\n * logger.clearLine()\n * }\n * logger.success('All files processed')\n * ```\n */\n clearLine(): this {\n const con = privateConsole.get(this)\n const stream = this.#getTargetStream()\n const streamObj = stream === 'stderr' ? con._stderr : con._stdout\n if (streamObj.isTTY) {\n streamObj.cursorTo(0)\n streamObj.clearLine(0)\n } else {\n streamObj.write('\\r\\x1b[K')\n }\n return this\n }\n}\n\nObject.defineProperties(\n Logger.prototype,\n Object.fromEntries(\n (() => {\n const entries: Array<[string | symbol, PropertyDescriptor]> = [\n [\n kGroupIndentationWidthSymbol,\n {\n ...consolePropAttributes,\n value: 2,\n },\n ],\n [\n Symbol.toStringTag,\n {\n __proto__: null,\n configurable: true,\n value: 'logger',\n } as PropertyDescriptor,\n ],\n ]\n for (const { 0: key, 1: value } of Object.entries(globalConsole)) {\n if (!(Logger.prototype as any)[key] && typeof value === 'function') {\n // Dynamically name the log method without using Object.defineProperty.\n const { [key]: func } = {\n [key](...args: unknown[]) {\n const con = privateConsole.get(this)\n const result = (con as any)[key](...args)\n return result === undefined || result === con ? this : result\n },\n }\n entries.push([\n key,\n {\n ...consolePropAttributes,\n value: func,\n },\n ])\n }\n }\n return entries\n })(),\n ),\n)\n\n/**\n * Default logger instance for the application.\n *\n * A pre-configured `Logger` instance that uses the standard `process.stdout`\n * and `process.stderr` streams. This is the recommended logger to import\n * and use throughout your application.\n *\n * @example\n * ```typescript\n * import { logger } from '@socketsecurity/lib'\n *\n * logger.log('Application started')\n * logger.success('Configuration loaded')\n * logger.indent()\n * logger.log('Using port 3000')\n * logger.dedent()\n * ```\n */\nexport const logger = new Logger()\n"],
|
|
5
|
+
"mappings": ";6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,EAAA,WAAAC,EAAA,0BAAAC,EAAA,uBAAAC,EAAA,WAAAC,IAAA,eAAAC,EAAAP,GAKA,IAAAQ,EAA+B,8DAC/BC,EAA2B,yCAC3BC,EAA2C,qBAC3CC,EAA+C,qBAoE/C,MAAMC,EAAgB,QAKhBC,EAAe,QAAQ,MACvBC,EAAmB,QAAQ,UAEjC,IAAIC,EAMJ,SAASC,KAAoBC,EAAiB,CAC5C,OAAIF,IAAa,SAIfA,EADkC,QAAQ,cAAc,EACjC,SAElBD,EACLC,EAGAE,CACF,CACF,CAOA,SAASC,GAAiB,CACxB,OAAO,EAAAC,OACT,CAqBO,MAAMjB,GAA6B,IAAM,CAC9C,MAAMkB,EAAiC,CACrC,UAAW,IACb,EAEMC,EAAgD,CACpD,UAAW,IACb,EACMC,EAAO,IAAM,CACjB,MAAMC,KAAY,EAAAC,SAAmB,EAC/BC,EAASP,EAAe,KAC9B,gBAAaE,EAAQ,CACnB,KAAMK,EAAO,IAAIF,EAAY,SAAM,MAAG,EACtC,KAAME,EAAO,KAAKF,EAAY,SAAM,GAAG,EACvC,QAASE,EAAO,MAAMF,EAAY,SAAM,QAAG,EAC3C,KAAME,EAAO,OAAOF,EAAY,SAAM,QAAG,CAC3C,CAAC,KACD,gBAAaH,CAAM,EAGnB,UAAWM,KAAYL,EACrB,OAAOA,EAAQK,CAAsD,CAEzE,EACA,UAAW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Ac,GACd,MAAO,QACT,CACF,CACF,EACA,SAAW,CAAE,EAAGmB,EAAK,EAAGQ,CAAM,IAAK,OAAO,QAAQ7C,CAAa,EAC7D,GAAI,CAAET,EAAO,UAAkB8C,CAAG,GAAK,OAAOQ,GAAU,WAAY,CAElE,KAAM,CAAE,CAACR,CAAG,EAAG0C,CAAK,EAAI,CACtB,CAAC1C,CAAG,KAAKhC,EAAiB,CACxB,MAAM+B,EAAMhB,EAAe,IAAI,IAAI,EAC7B4C,EAAU5B,EAAYC,CAAG,EAAE,GAAGhC,CAAI,EACxC,OAAO2D,IAAW,QAAaA,IAAW5B,EAAM,KAAO4B,CACzD,CACF,EACAc,EAAQ,KAAK,CACXzC,EACA,CACE,GAAGnB,EACH,MAAO6D,CACT,CACF,CAAC,CACH,CAEF,OAAOD,CACT,GAAG,CACL,CACF,EAoBO,MAAMpF,EAAS,IAAIH",
|
|
6
|
+
"names": ["logger_exports", "__export", "LOG_SYMBOLS", "Logger", "incLogCallCountSymbol", "lastWasBlankSymbol", "logger", "__toCommonJS", "import_is_unicode_supported", "import_yoctocolors_cjs", "import_objects", "import_strings", "globalConsole", "ReflectApply", "ReflectConstruct", "_Console", "constructConsole", "args", "getYoctocolors", "yoctocolorsCjs", "target", "handler", "init", "supported", "isUnicodeSupported", "colors", "trapName", "fn", "boundConsoleEntries", "n", "consolePropAttributes", "maxIndentation", "privateConsole", "consoleSymbols", "kGroupIndentationWidthSymbol", "s", "#parent", "#boundStream", "#stderrLogger", "#stdoutLogger", "#stderrIndention", "#stdoutIndention", "#stderrLastWasBlank", "#stdoutLastWasBlank", "#logCallCount", "#constructorArgs", "#options", "options", "con", "key", "method", "instance", "#getRoot", "#getIndent", "stream", "root", "#setIndent", "value", "#getLastWasBlank", "#setLastWasBlank", "#getTargetStream", "#apply", "methodName", "text", "hasText", "targetStream", "indent", "logArgs", "#stripSymbols", "#symbolApply", "symbolType", "extras", "message", "label", "name", "f", "result", "spaces", "current", "stderrCurrent", "stdoutCurrent", "obj", "data", "length", "spacesToAdd", "msg", "indentedMsg", "tabularData", "properties", "streamObj", "entries", "func"]
|
|
7
7
|
}
|