@adaptic/utils 0.0.901 → 0.0.903
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/dist/index.cjs +83 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +72 -28
- package/dist/index.mjs.map +1 -1
- package/dist/test.js +56 -12
- package/dist/test.js.map +1 -1
- package/dist/types/display-manager.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -12,15 +12,12 @@ import require$$0$3 from 'stream';
|
|
|
12
12
|
import require$$7 from 'url';
|
|
13
13
|
import require$$0$1 from 'zlib';
|
|
14
14
|
import require$$0$2 from 'buffer';
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import fs__default from 'fs';
|
|
18
|
-
import * as path from 'path';
|
|
19
|
-
import path__default from 'path';
|
|
15
|
+
import require$$0$5 from 'fs';
|
|
16
|
+
import require$$1$2 from 'path';
|
|
20
17
|
import require$$4$1 from 'assert';
|
|
21
|
-
import require$$1$
|
|
22
|
-
import require$$1$
|
|
23
|
-
import require$$0$
|
|
18
|
+
import require$$1$3 from 'tty';
|
|
19
|
+
import require$$1$4 from 'util';
|
|
20
|
+
import require$$0$6 from 'os';
|
|
24
21
|
|
|
25
22
|
/**
|
|
26
23
|
* Configurable logger interface compatible with Pino and other logging libraries.
|
|
@@ -12136,6 +12133,33 @@ Object.defineProperties(createChalk.prototype, styles);
|
|
|
12136
12133
|
const chalk = createChalk();
|
|
12137
12134
|
createChalk({level: stderrColor ? stderrColor.level : 0});
|
|
12138
12135
|
|
|
12136
|
+
// Detect whether we are running in a Node.js environment with a real stdout.
|
|
12137
|
+
// In browsers (or environments without process.stdout) all terminal / fs
|
|
12138
|
+
// operations become no-ops so the library can be safely imported client-side.
|
|
12139
|
+
const isNode = typeof process !== "undefined" &&
|
|
12140
|
+
typeof process.stdout !== "undefined" &&
|
|
12141
|
+
typeof process.stdout.write === "function";
|
|
12142
|
+
// Lazy-load Node-only dependencies so bundlers can tree-shake / stub them.
|
|
12143
|
+
// chalk is kept as a static import (ESM-only in v5) — Rollup handles it.
|
|
12144
|
+
// readline, fs, and path are loaded at runtime only in Node.
|
|
12145
|
+
let clearLine;
|
|
12146
|
+
let cursorTo;
|
|
12147
|
+
let fs;
|
|
12148
|
+
let path;
|
|
12149
|
+
if (isNode) {
|
|
12150
|
+
try {
|
|
12151
|
+
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
12152
|
+
const readline = require("readline");
|
|
12153
|
+
clearLine = readline.clearLine;
|
|
12154
|
+
cursorTo = readline.cursorTo;
|
|
12155
|
+
fs = require("fs");
|
|
12156
|
+
path = require("path");
|
|
12157
|
+
/* eslint-enable @typescript-eslint/no-require-imports */
|
|
12158
|
+
}
|
|
12159
|
+
catch {
|
|
12160
|
+
// Silently degrade — all operations will be no-ops.
|
|
12161
|
+
}
|
|
12162
|
+
}
|
|
12139
12163
|
class DisplayManager {
|
|
12140
12164
|
static instance;
|
|
12141
12165
|
promptText = "";
|
|
@@ -12153,9 +12177,19 @@ class DisplayManager {
|
|
|
12153
12177
|
* Logs a message while preserving the prompt at the bottom
|
|
12154
12178
|
*/
|
|
12155
12179
|
log(message, options) {
|
|
12180
|
+
if (!isNode) {
|
|
12181
|
+
// In browser environments, fall back to console
|
|
12182
|
+
const level = options?.type === "error"
|
|
12183
|
+
? "error"
|
|
12184
|
+
: options?.type === "warn"
|
|
12185
|
+
? "warn"
|
|
12186
|
+
: "log";
|
|
12187
|
+
console[level](message);
|
|
12188
|
+
return;
|
|
12189
|
+
}
|
|
12156
12190
|
// Clear the current prompt line
|
|
12157
|
-
clearLine(process.stdout, 0);
|
|
12158
|
-
cursorTo(process.stdout, 0);
|
|
12191
|
+
clearLine?.(process.stdout, 0);
|
|
12192
|
+
cursorTo?.(process.stdout, 0);
|
|
12159
12193
|
// Format the timestamp
|
|
12160
12194
|
const date = new Date();
|
|
12161
12195
|
const timestamp = date.toLocaleString("en-US", {
|
|
@@ -12166,11 +12200,13 @@ class DisplayManager {
|
|
|
12166
12200
|
// Build the log message
|
|
12167
12201
|
let logMessage = `[${timestamp}]${options?.source ? ` [${options.source}] ` : ""}${account ? ` [${account}] ` : ""}${symbol ? ` [${symbol}] ` : ""}${message}`;
|
|
12168
12202
|
// Add color based on type
|
|
12169
|
-
if (
|
|
12170
|
-
|
|
12171
|
-
|
|
12172
|
-
|
|
12173
|
-
|
|
12203
|
+
if (chalk) {
|
|
12204
|
+
if (options?.type === "error") {
|
|
12205
|
+
logMessage = chalk.red(logMessage);
|
|
12206
|
+
}
|
|
12207
|
+
else if (options?.type === "warn") {
|
|
12208
|
+
logMessage = chalk.yellow(logMessage);
|
|
12209
|
+
}
|
|
12174
12210
|
}
|
|
12175
12211
|
// Write the log message
|
|
12176
12212
|
process.stdout.write(logMessage + "\n");
|
|
@@ -12190,6 +12226,8 @@ class DisplayManager {
|
|
|
12190
12226
|
* Writes a log entry to a symbol-specific log file
|
|
12191
12227
|
*/
|
|
12192
12228
|
writeSymbolLog(symbol, date, logMessage, options) {
|
|
12229
|
+
if (!fs || !path)
|
|
12230
|
+
return;
|
|
12193
12231
|
try {
|
|
12194
12232
|
// Create logs directory if it doesn't exist
|
|
12195
12233
|
if (!fs.existsSync("logs")) {
|
|
@@ -12216,6 +12254,8 @@ class DisplayManager {
|
|
|
12216
12254
|
* Writes a log entry to a generic log file when no symbol is provided
|
|
12217
12255
|
*/
|
|
12218
12256
|
writeGenericLog(date, logMessage, options) {
|
|
12257
|
+
if (!fs || !path)
|
|
12258
|
+
return;
|
|
12219
12259
|
try {
|
|
12220
12260
|
// Create logs directory if it doesn't exist
|
|
12221
12261
|
if (!fs.existsSync("logs")) {
|
|
@@ -12240,11 +12280,15 @@ class DisplayManager {
|
|
|
12240
12280
|
}
|
|
12241
12281
|
}
|
|
12242
12282
|
writePrompt() {
|
|
12283
|
+
if (!isNode)
|
|
12284
|
+
return;
|
|
12243
12285
|
process.stdout.write(this.promptText);
|
|
12244
12286
|
}
|
|
12245
12287
|
clearPrompt() {
|
|
12246
|
-
|
|
12247
|
-
|
|
12288
|
+
if (!isNode)
|
|
12289
|
+
return;
|
|
12290
|
+
clearLine?.(process.stdout, 0);
|
|
12291
|
+
cursorTo?.(process.stdout, 0);
|
|
12248
12292
|
}
|
|
12249
12293
|
restorePrompt() {
|
|
12250
12294
|
this.writePrompt();
|
|
@@ -15217,8 +15261,8 @@ function requireMain () {
|
|
|
15217
15261
|
|
|
15218
15262
|
*/
|
|
15219
15263
|
|
|
15220
|
-
const fs =
|
|
15221
|
-
const path =
|
|
15264
|
+
const fs = require$$0$5;
|
|
15265
|
+
const path = require$$1$2;
|
|
15222
15266
|
|
|
15223
15267
|
function log (message /*: string */) {
|
|
15224
15268
|
console.log(`[dotenv][DEBUG] ${message}`);
|
|
@@ -17026,8 +17070,8 @@ var hasRequiredSupportsColor;
|
|
|
17026
17070
|
function requireSupportsColor () {
|
|
17027
17071
|
if (hasRequiredSupportsColor) return supportsColor_1;
|
|
17028
17072
|
hasRequiredSupportsColor = 1;
|
|
17029
|
-
const os = require$$0$
|
|
17030
|
-
const tty = require$$1$
|
|
17073
|
+
const os = require$$0$6;
|
|
17074
|
+
const tty = require$$1$3;
|
|
17031
17075
|
const hasFlag = requireHasFlag();
|
|
17032
17076
|
|
|
17033
17077
|
const {env} = process;
|
|
@@ -17173,8 +17217,8 @@ function requireNode$1 () {
|
|
|
17173
17217
|
if (hasRequiredNode$1) return node$1.exports;
|
|
17174
17218
|
hasRequiredNode$1 = 1;
|
|
17175
17219
|
(function (module, exports$1) {
|
|
17176
|
-
const tty = require$$1$
|
|
17177
|
-
const util = require$$1$
|
|
17220
|
+
const tty = require$$1$3;
|
|
17221
|
+
const util = require$$1$4;
|
|
17178
17222
|
|
|
17179
17223
|
/**
|
|
17180
17224
|
* This is the Node.js implementation of `debug()`.
|
|
@@ -19520,7 +19564,7 @@ function requireUrljoin () {
|
|
|
19520
19564
|
|
|
19521
19565
|
var extend = requireExtend();
|
|
19522
19566
|
var url = require$$7;
|
|
19523
|
-
var path =
|
|
19567
|
+
var path = require$$1$2;
|
|
19524
19568
|
|
|
19525
19569
|
/**
|
|
19526
19570
|
* Join two or more url pieces into one.
|
|
@@ -47159,7 +47203,7 @@ function requireBuffer_list () {
|
|
|
47159
47203
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (String )(input); }
|
|
47160
47204
|
var _require = require$$0$2,
|
|
47161
47205
|
Buffer = _require.Buffer;
|
|
47162
|
-
var _require2 = require$$1$
|
|
47206
|
+
var _require2 = require$$1$4,
|
|
47163
47207
|
inspect = _require2.inspect;
|
|
47164
47208
|
var custom = inspect && inspect.custom || 'inspect';
|
|
47165
47209
|
function copyBuffer(src, target, offset) {
|
|
@@ -47658,7 +47702,7 @@ function requireNode () {
|
|
|
47658
47702
|
* For Node.js, simply re-export the core `util.deprecate` function.
|
|
47659
47703
|
*/
|
|
47660
47704
|
|
|
47661
|
-
node = require$$1$
|
|
47705
|
+
node = require$$1$4.deprecate;
|
|
47662
47706
|
return node;
|
|
47663
47707
|
}
|
|
47664
47708
|
|
|
@@ -49044,7 +49088,7 @@ function require_stream_readable () {
|
|
|
49044
49088
|
}
|
|
49045
49089
|
|
|
49046
49090
|
/*<replacement>*/
|
|
49047
|
-
var debugUtil = require$$1$
|
|
49091
|
+
var debugUtil = require$$1$4;
|
|
49048
49092
|
var debug;
|
|
49049
49093
|
if (debugUtil && debugUtil.debuglog) {
|
|
49050
49094
|
debug = debugUtil.debuglog('stream');
|
|
@@ -50896,7 +50940,7 @@ function requireHelpers () {
|
|
|
50896
50940
|
if (hasRequiredHelpers) return helpers;
|
|
50897
50941
|
hasRequiredHelpers = 1;
|
|
50898
50942
|
|
|
50899
|
-
const util = require$$1$
|
|
50943
|
+
const util = require$$1$4;
|
|
50900
50944
|
|
|
50901
50945
|
helpers.IncompleteBufferError = IncompleteBufferError;
|
|
50902
50946
|
|