@reliverse/relinka 1.2.2 → 1.2.4

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.
@@ -9,6 +9,8 @@ export declare class Relinka {
9
9
  time?: Date;
10
10
  timeout?: ReturnType<typeof setTimeout>;
11
11
  };
12
+ _paused: boolean;
13
+ _queue: any[];
12
14
  _mockFn?: RelinkaOptions["mockFn"];
13
15
  constructor(options?: Partial<RelinkaOptions>);
14
16
  get level(): any;
@@ -27,6 +29,7 @@ export declare class Relinka {
27
29
  _wrapStream(stream: NodeJS.WriteStream | undefined, type: LogType): void;
28
30
  restoreStd(): void;
29
31
  _restoreStream(stream?: NodeJS.WriteStream): void;
32
+ clear(clearConsole?: boolean): void;
30
33
  pauseLogs(): void;
31
34
  resumeLogs(): void;
32
35
  mockTypes(mockFn?: RelinkaOptions["mockFn"]): void;
@@ -1,11 +1,14 @@
1
1
  import { defu } from "defu";
2
2
  import { LogTypes } from "../../components/levels/levels.js";
3
3
  import { isLogObj } from "../../utils/log.js";
4
- let paused = false;
4
+ const paused = false;
5
5
  const queue = [];
6
6
  export class Relinka {
7
7
  options;
8
8
  _lastLog;
9
+
10
+ _paused;
11
+ _queue;
9
12
  _mockFn;
10
13
  constructor(options = {}) {
11
14
  const types = options.types || LogTypes;
@@ -43,6 +46,8 @@ export class Relinka {
43
46
  this.mockTypes();
44
47
  }
45
48
  this._lastLog = {};
49
+ this._paused = false;
50
+ this._queue = [];
46
51
  }
47
52
  get level() {
48
53
  return this.options.level;
@@ -148,13 +153,21 @@ export class Relinka {
148
153
  stream.write = stream.__write;
149
154
  delete stream.__write;
150
155
  }
156
+ }
157
+ clear(clearConsole = false) {
158
+ this._lastLog = {};
159
+ this._queue = [];
160
+ this._paused = false;
161
+ if (clearConsole && typeof console.clear === "function") {
162
+ console.clear();
163
+ }
151
164
  }
152
165
  pauseLogs() {
153
- paused = true;
166
+ this._paused = true;
154
167
  }
155
168
  resumeLogs() {
156
- paused = false;
157
- const _queue = queue.splice(0);
169
+ this._paused = false;
170
+ const _queue = this._queue.splice(0);
158
171
  for (const item of _queue) {
159
172
  item[0]._logFn(item[1], item[2]);
160
173
  }
@@ -170,10 +183,11 @@ export class Relinka {
170
183
  this[type].raw = this[type];
171
184
  }
172
185
  }
186
+
173
187
  _wrapLogFn(defaults, isRaw) {
174
188
  return (...args) => {
175
- if (paused) {
176
- queue.push([this, defaults, args, isRaw]);
189
+ if (this._paused) {
190
+ this._queue.push([this, defaults, args, isRaw]);
177
191
  return;
178
192
  }
179
193
  return this._logFn(defaults, args, isRaw);
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@reliverse/relinka",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "author": "blefnk",
5
5
  "type": "module",
6
6
  "description": "@reliverse/relinka is a powerful logger for your terminal.",
7
7
  "scripts": {
8
- "dev": "bun examples/main.ts",
8
+ "dev": "tsx examples/main.ts",
9
9
  "check": "redrun typecheck lint format attw",
10
10
  "release": "bumpp && bun check && bun pub",
11
- "build:jsr": "bun build.optim.ts --jsr",
12
- "build:npm": "unbuild && bun build.optim.ts",
11
+ "build:jsr": "tsx build.optim.ts --jsr",
12
+ "build:npm": "unbuild && tsx build.optim.ts",
13
13
  "build": "redrun build:jsr build:npm optimize",
14
- "pub:jsr": "bun build.publish.ts --jsr",
15
- "pub:npm": "bun build.publish.ts",
16
- "pub:dry": "bun build.publish.ts --dry-run",
14
+ "pub:jsr": "tsx build.publish.ts --jsr",
15
+ "pub:npm": "tsx build.publish.ts",
16
+ "pub:dry": "tsx build.publish.ts --dry-run",
17
17
  "pub": "redrun pub:npm pub:jsr",
18
18
  "typecheck": "tsc --noEmit",
19
19
  "lint": "eslint --cache --fix .",
@@ -69,7 +69,7 @@
69
69
  "log-update": "^6.1.0",
70
70
  "mute-stream": "^2.0.0",
71
71
  "node-emoji": "^2.1.3",
72
- "nypm": "^0.3.12",
72
+ "nypm": "^0.4.0",
73
73
  "ora": "^8.1.1",
74
74
  "pathe": "^1.1.2",
75
75
  "picocolors": "^1.1.1",
@@ -87,7 +87,7 @@
87
87
  "devDependencies": {
88
88
  "@arethetypeswrong/cli": "^0.17.0",
89
89
  "@biomejs/biome": "1.9.4",
90
- "@cspell/dict-npm": "^5.1.13",
90
+ "@cspell/dict-npm": "^5.1.14",
91
91
  "@eslint/js": "^9.15.0",
92
92
  "@types/ansi-diff-stream": "^1.2.3",
93
93
  "@types/bun": "^1.1.14",
@@ -110,10 +110,11 @@
110
110
  "knip": "^5.38.1",
111
111
  "mock-stdin": "^1.0.0",
112
112
  "printj": "^1.3.1",
113
- "putout": "^36.13.1",
113
+ "putout": "^36.14.0",
114
114
  "redrun": "^11.0.5",
115
115
  "sentencer": "^0.2.1",
116
116
  "strip-comments": "^2.0.1",
117
+ "tsx": "^4.19.2",
117
118
  "typescript": "^5.7.2",
118
119
  "typescript-eslint": "^8.16.0",
119
120
  "unbuild": "^2.0.0",