@towles/tool 0.0.120 → 0.0.121

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.
Files changed (63) hide show
  1. package/node_modules/@towles/shared/package.json +15 -0
  2. package/node_modules/@towles/shared/src/date-utils.test.ts +97 -0
  3. package/node_modules/@towles/shared/src/date-utils.ts +54 -0
  4. package/node_modules/@towles/shared/src/fs.ts +19 -0
  5. package/node_modules/@towles/shared/src/git/branch-name.test.ts +83 -0
  6. package/node_modules/@towles/shared/src/git/branch-name.ts +10 -0
  7. package/node_modules/@towles/shared/src/git/exec.ts +41 -0
  8. package/node_modules/@towles/shared/src/git/gh-cli-wrapper.test.ts +55 -0
  9. package/node_modules/@towles/shared/src/git/gh-cli-wrapper.ts +74 -0
  10. package/node_modules/@towles/shared/src/index.ts +8 -0
  11. package/node_modules/@towles/shared/src/render.test.ts +71 -0
  12. package/node_modules/@towles/shared/src/render.ts +36 -0
  13. package/package.json +4 -1
  14. package/packages/agentboard/apps/tui/src/components/DetailPanel.tsx +62 -1
  15. package/packages/agentboard/packages/runtime/package.json +1 -0
  16. package/packages/agentboard/packages/runtime/src/agents/watchers/claude-code.test.ts +38 -1
  17. package/packages/agentboard/packages/runtime/src/agents/watchers/claude-code.ts +106 -31
  18. package/packages/agentboard/packages/runtime/src/agents/watchers/claude-pid.test.ts +74 -0
  19. package/packages/agentboard/packages/runtime/src/agents/watchers/claude-pid.ts +57 -0
  20. package/packages/agentboard/packages/runtime/src/agents/watchers/claude-usage.test.ts +148 -0
  21. package/packages/agentboard/packages/runtime/src/agents/watchers/claude-usage.ts +78 -0
  22. package/packages/agentboard/packages/runtime/src/contracts/agent.ts +17 -0
  23. package/packages/agentboard/packages/runtime/src/server/pane-scanner.ts +10 -4
  24. package/packages/shared/node_modules/consola/LICENSE +47 -0
  25. package/packages/shared/node_modules/consola/README.md +352 -0
  26. package/packages/shared/node_modules/consola/basic.d.ts +1 -0
  27. package/packages/shared/node_modules/consola/browser.d.ts +1 -0
  28. package/packages/shared/node_modules/consola/core.d.ts +1 -0
  29. package/packages/shared/node_modules/consola/dist/basic.cjs +32 -0
  30. package/packages/shared/node_modules/consola/dist/basic.d.cts +23 -0
  31. package/packages/shared/node_modules/consola/dist/basic.d.mts +21 -0
  32. package/packages/shared/node_modules/consola/dist/basic.d.ts +23 -0
  33. package/packages/shared/node_modules/consola/dist/basic.mjs +24 -0
  34. package/packages/shared/node_modules/consola/dist/browser.cjs +84 -0
  35. package/packages/shared/node_modules/consola/dist/browser.d.cts +23 -0
  36. package/packages/shared/node_modules/consola/dist/browser.d.mts +21 -0
  37. package/packages/shared/node_modules/consola/dist/browser.d.ts +23 -0
  38. package/packages/shared/node_modules/consola/dist/browser.mjs +76 -0
  39. package/packages/shared/node_modules/consola/dist/chunks/prompt.cjs +288 -0
  40. package/packages/shared/node_modules/consola/dist/chunks/prompt.mjs +280 -0
  41. package/packages/shared/node_modules/consola/dist/core.cjs +517 -0
  42. package/packages/shared/node_modules/consola/dist/core.d.cts +459 -0
  43. package/packages/shared/node_modules/consola/dist/core.d.mts +459 -0
  44. package/packages/shared/node_modules/consola/dist/core.d.ts +459 -0
  45. package/packages/shared/node_modules/consola/dist/core.mjs +512 -0
  46. package/packages/shared/node_modules/consola/dist/index.cjs +663 -0
  47. package/packages/shared/node_modules/consola/dist/index.d.cts +24 -0
  48. package/packages/shared/node_modules/consola/dist/index.d.mts +22 -0
  49. package/packages/shared/node_modules/consola/dist/index.d.ts +24 -0
  50. package/packages/shared/node_modules/consola/dist/index.mjs +651 -0
  51. package/packages/shared/node_modules/consola/dist/shared/consola.DCGIlDNP.cjs +75 -0
  52. package/packages/shared/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs +72 -0
  53. package/packages/shared/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs +288 -0
  54. package/packages/shared/node_modules/consola/dist/shared/consola.DwRq1yyg.cjs +312 -0
  55. package/packages/shared/node_modules/consola/dist/utils.cjs +64 -0
  56. package/packages/shared/node_modules/consola/dist/utils.d.cts +286 -0
  57. package/packages/shared/node_modules/consola/dist/utils.d.mts +286 -0
  58. package/packages/shared/node_modules/consola/dist/utils.d.ts +286 -0
  59. package/packages/shared/node_modules/consola/dist/utils.mjs +54 -0
  60. package/packages/shared/node_modules/consola/lib/index.cjs +10 -0
  61. package/packages/shared/node_modules/consola/package.json +136 -0
  62. package/packages/shared/node_modules/consola/utils.d.ts +1 -0
  63. package/packages/shared/tsconfig.json +0 -16
@@ -14,21 +14,27 @@ const AGENT_TITLE_PATTERNS: Record<string, string[]> = {
14
14
  opencode: ["opencode"],
15
15
  };
16
16
 
17
- /** Build parent->children map from a single ps snapshot (avoids per-pane pgrep calls). */
17
+ /** Build parent->children map from a single ps snapshot (avoids per-pane pgrep calls).
18
+ * Skips stopped (T) and zombie (Z) processes — they have a comm but aren't actively running. */
18
19
  function buildProcessTree(): { childrenOf: Map<number, number[]>; commOf: Map<number, string> } {
19
20
  const childrenOf = new Map<number, number[]>();
20
21
  const commOf = new Map<number, string>();
21
- const psResult = Bun.spawnSync(["ps", "-eo", "pid=,ppid=,comm="], {
22
+ const psResult = Bun.spawnSync(["ps", "-eo", "pid=,ppid=,stat=,comm="], {
22
23
  stdout: "pipe",
23
24
  stderr: "pipe",
24
25
  });
25
26
  for (const line of psResult.stdout.toString().trim().split("\n")) {
26
27
  const parts = line.trim().split(/\s+/);
27
- if (parts.length < 3) continue;
28
+ if (parts.length < 4) continue;
28
29
  const pid = Number.parseInt(parts[0], 10);
29
30
  const ppid = Number.parseInt(parts[1], 10);
30
- const comm = parts.slice(2).join(" ").toLowerCase();
31
+ const stat = parts[2] ?? "";
32
+ const comm = parts.slice(3).join(" ").toLowerCase();
31
33
  if (Number.isNaN(pid) || Number.isNaN(ppid)) continue;
34
+ // First char of stat is the primary process state.
35
+ // T = stopped (e.g. Ctrl+Z), Z = zombie, X = dead. Treat all as not-running.
36
+ const state = stat.charAt(0);
37
+ if (state === "T" || state === "Z" || state === "X") continue;
32
38
  commOf.set(pid, comm);
33
39
  let arr = childrenOf.get(ppid);
34
40
  if (!arr) {
@@ -0,0 +1,47 @@
1
+ MIT License
2
+
3
+ Copyright (c) Pooya Parsa <pooya@pi0.io>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ ---
24
+
25
+ Prompt support is based on https://github.com/bombshell-dev/clack
26
+
27
+ MIT License
28
+
29
+ Copyright (c) Nate Moore
30
+
31
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
32
+
33
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
34
+
35
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36
+
37
+ ---
38
+
39
+ Color support is based on https://github.com/jorgebucaran/colorette
40
+
41
+ Copyright © Jorge Bucaran <https://jorgebucaran.com>
42
+
43
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
44
+
45
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
46
+
47
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,352 @@
1
+ # 🐨 Consola
2
+
3
+ > Elegant Console Wrapper
4
+
5
+ [![npm version][npm-version-src]][npm-version-href]
6
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
7
+ [![bundle][bundle-src]][bundle-href]
8
+
9
+ <!-- [![Codecov][codecov-src]][codecov-href] -->
10
+
11
+ ## Why Consola?
12
+
13
+ 👌&nbsp; Easy to use<br>
14
+ 💅&nbsp; Fancy output with fallback for minimal environments<br>
15
+ 🔌&nbsp; Pluggable reporters<br>
16
+ 💻&nbsp; Consistent command line interface (CLI) experience<br>
17
+ 🏷&nbsp; Tag support<br>
18
+ 🚏&nbsp; Redirect `console` and `stdout/stderr` to consola and easily restore redirect.<br>
19
+ 🌐&nbsp; Browser support<br>
20
+ ⏯&nbsp; Pause/Resume support<br>
21
+ 👻&nbsp; Mocking support<br>
22
+ 👮‍♂️&nbsp; Spam prevention by throttling logs<br>
23
+ ❯&nbsp; Interactive prompt support powered by [`clack`](https://github.com/natemoo-re/clack)<br>
24
+
25
+ ## Installation
26
+
27
+ Using npm:
28
+
29
+ ```bash
30
+ npm i consola
31
+ ```
32
+
33
+ Using yarn:
34
+
35
+ ```bash
36
+ yarn add consola
37
+ ```
38
+
39
+ Using pnpm:
40
+
41
+ ```bash
42
+ pnpm i consola
43
+ ```
44
+
45
+ ## Getting Started
46
+
47
+ ```js
48
+ // ESM
49
+ import { consola, createConsola } from "consola";
50
+
51
+ // CommonJS
52
+ const { consola, createConsola } = require("consola");
53
+
54
+ consola.info("Using consola 3.0.0");
55
+ consola.start("Building project...");
56
+ consola.warn("A new version of consola is available: 3.0.1");
57
+ consola.success("Project built!");
58
+ consola.error(new Error("This is an example error. Everything is fine!"));
59
+ consola.box("I am a simple box");
60
+ await consola.prompt("Deploy to the production?", {
61
+ type: "confirm",
62
+ });
63
+ ```
64
+
65
+ Will display in the terminal:
66
+
67
+ ![consola-screenshot](https://github.com/unjs/consola/assets/904724/0e511ee6-2543-43ab-9eda-152f07134d94)
68
+
69
+ You can use smaller core builds without fancy reporter to save 80% of the bundle size:
70
+
71
+ ```ts
72
+ import { consola, createConsola } from "consola/basic";
73
+ import { consola, createConsola } from "consola/browser";
74
+ import { createConsola } from "consola/core";
75
+ ```
76
+
77
+ ## Consola Methods
78
+
79
+ #### `<type>(logObject)` `<type>(args...)`
80
+
81
+ Log to all reporters.
82
+
83
+ Example: `consola.info('Message')`
84
+
85
+ #### `await prompt(message, { type, cancel })`
86
+
87
+ Show an input prompt. Type can either of `text`, `confirm`, `select` or `multiselect`.
88
+
89
+ If prompt is canceled by user (with Ctrol+C), default value will be resolved by default. This strategy can be configured by setting `{ cancel: "..." }` option:
90
+
91
+ - `"default"` - Resolve the promise with the `default` value or `initial` value.
92
+ - `"undefined`" - Resolve the promise with `undefined`.
93
+ - `"null"` - Resolve the promise with `null`.
94
+ - `"symbol"` - Resolve the promise with a symbol `Symbol.for("cancel")`.
95
+ - `"reject"` - Reject the promise with an error.
96
+
97
+ See [examples/prompt.ts](./examples/prompt.ts) for usage examples.
98
+
99
+ #### `addReporter(reporter)`
100
+
101
+ - Aliases: `add`
102
+
103
+ Register a custom reporter instance.
104
+
105
+ #### `removeReporter(reporter?)`
106
+
107
+ - Aliases: `remove`, `clear`
108
+
109
+ Remove a registered reporter.
110
+
111
+ If no arguments are passed all reporters will be removed.
112
+
113
+ #### `setReporters(reporter|reporter[])`
114
+
115
+ Replace all reporters.
116
+
117
+ #### `create(options)`
118
+
119
+ Create a new `Consola` instance and inherit all parent options for defaults.
120
+
121
+ #### `withDefaults(defaults)`
122
+
123
+ Create a new `Consola` instance with provided defaults
124
+
125
+ #### `withTag(tag)`
126
+
127
+ - Aliases: `withScope`
128
+
129
+ Create a new `Consola` instance with that tag.
130
+
131
+ #### `wrapConsole()` `restoreConsole()`
132
+
133
+ Globally redirect all `console.log`, etc calls to consola handlers.
134
+
135
+ #### `wrapStd()` `restoreStd()`
136
+
137
+ Globally redirect all stdout/stderr outputs to consola.
138
+
139
+ #### `wrapAll()` `restoreAll()`
140
+
141
+ Wrap both, std and console.
142
+
143
+ console uses std in the underlying so calling `wrapStd` redirects console too.
144
+ Benefit of this function is that things like `console.info` will be correctly redirected to the corresponding type.
145
+
146
+ #### `pauseLogs()` `resumeLogs()`
147
+
148
+ - Aliases: `pause`/`resume`
149
+
150
+ **Globally** pause and resume logs.
151
+
152
+ Consola will enqueue all logs when paused and then sends them to the reported when resumed.
153
+
154
+ #### `mockTypes`
155
+
156
+ - Aliases: `mock`
157
+
158
+ Mock all types. Useful for using with tests.
159
+
160
+ The first argument passed to `mockTypes` should be a callback function accepting `(typeName, type)` and returning the mocked value:
161
+
162
+ ```js
163
+ // Jest
164
+ consola.mockTypes((typeName, type) => jest.fn());
165
+ // Vitest
166
+ consola.mockTypes((typeName, type) => vi.fn());
167
+ ```
168
+
169
+ Please note that with the example above, everything is mocked independently for each type. If you need one mocked fn create it outside:
170
+
171
+ ```js
172
+ // Jest
173
+ const fn = jest.fn();
174
+ // Vitest
175
+ const fn = vi.fn();
176
+ consola.mockTypes(() => fn);
177
+ ```
178
+
179
+ If callback function returns a _falsy_ value, that type won't be mocked.
180
+
181
+ For example if you just need to mock `consola.fatal`:
182
+
183
+ ```js
184
+ // Jest
185
+ consola.mockTypes((typeName) => typeName === "fatal" && jest.fn());
186
+ // Vitest
187
+ consola.mockTypes((typeName) => typeName === "fatal" && vi.fn());
188
+ ```
189
+
190
+ **NOTE:** Any instance of consola that inherits the mocked instance, will apply provided callback again.
191
+ This way, mocking works for `withTag` scoped loggers without need to extra efforts.
192
+
193
+ ## Custom Reporters
194
+
195
+ Consola ships with 3 built-in reporters out of the box. A fancy colored reporter by default and fallsback to a basic reporter if running in a testing or CI environment detected using [unjs/std-env](https://github.com/unjs/std-env) and a basic browser reporter.
196
+
197
+ You can create a new reporter object that implements `{ log(logObject): () => { } }` interface.
198
+
199
+ **Example:** Simple JSON reporter
200
+
201
+ ```ts
202
+ import { createConsola } from "consola";
203
+
204
+ const consola = createConsola({
205
+ reporters: [
206
+ {
207
+ log: (logObj) => {
208
+ console.log(JSON.stringify(logObj));
209
+ },
210
+ },
211
+ ],
212
+ });
213
+
214
+ // Prints {"date":"2023-04-18T12:43:38.693Z","args":["foo bar"],"type":"log","level":2,"tag":""}
215
+ consola.log("foo bar");
216
+ ```
217
+
218
+ ## Log Level
219
+
220
+ Consola only shows logs with configured log level or below. (Default is `3`)
221
+
222
+ Available log levels:
223
+
224
+ - `0`: Fatal and Error
225
+ - `1`: Warnings
226
+ - `2`: Normal logs
227
+ - `3`: Informational logs, success, fail, ready, start, ...
228
+ - `4`: Debug logs
229
+ - `5`: Trace logs
230
+ - `-999`: Silent
231
+ - `+999`: Verbose logs
232
+
233
+ You can set the log level by either:
234
+
235
+ - Passing `level` option to `createConsola`
236
+ - Setting `consola.level` on instance
237
+ - Using the `CONSOLA_LEVEL` environment variable (not supported for browser and core builds).
238
+
239
+ ## Log Types
240
+
241
+ Log types are exposed as `consola.[type](...)` and each is a preset of styles and log level.
242
+
243
+ A list of all available built-in types is [available here](./src/constants.ts).
244
+
245
+ ## Creating a new instance
246
+
247
+ Consola has a global instance and is recommended to use everywhere.
248
+ In case more control is needed, create a new instance.
249
+
250
+ ```js
251
+ import { createConsola } from "consola";
252
+
253
+ const logger = createConsola({
254
+ // level: 4,
255
+ // fancy: true | false
256
+ // formatOptions: {
257
+ // columns: 80,
258
+ // colors: false,
259
+ // compact: false,
260
+ // date: false,
261
+ // },
262
+ });
263
+ ```
264
+
265
+ ## Integrations
266
+
267
+ ### With jest or vitest
268
+
269
+ ```js
270
+ describe("your-consola-mock-test", () => {
271
+ beforeAll(() => {
272
+ // Redirect std and console to consola too
273
+ // Calling this once is sufficient
274
+ consola.wrapAll();
275
+ });
276
+
277
+ beforeEach(() => {
278
+ // Re-mock consola before each test call to remove
279
+ // calls from before
280
+ // Jest
281
+ consola.mockTypes(() => jest.fn());
282
+ // Vitest
283
+ consola.mockTypes(() => vi.fn());
284
+ });
285
+
286
+ test("your test", async () => {
287
+ // Some code here
288
+
289
+ // Let's retrieve all messages of `consola.log`
290
+ // Get the mock and map all calls to their first argument
291
+ const consolaMessages = consola.log.mock.calls.map((c) => c[0]);
292
+ expect(consolaMessages).toContain("your message");
293
+ });
294
+ });
295
+ ```
296
+
297
+ ### With jsdom
298
+
299
+ ```js
300
+ {
301
+ new jsdom.VirtualConsole().sendTo(consola);
302
+ }
303
+ ```
304
+
305
+ ## Console Utils
306
+
307
+ ```ts
308
+ // ESM
309
+ import {
310
+ stripAnsi,
311
+ centerAlign,
312
+ rightAlign,
313
+ leftAlign,
314
+ align,
315
+ box,
316
+ colors,
317
+ getColor,
318
+ colorize,
319
+ } from "consola/utils";
320
+
321
+ // CommonJS
322
+ const { stripAnsi } = require("consola/utils");
323
+ ```
324
+
325
+ ## Raw logging methods
326
+
327
+ Objects sent to the reporter could lead to unexpected output when object is close to internal object structure containing either `message` or `args` props. To enforce the object to be interpreted as pure object, you can use the `raw` method chained to any log type.
328
+
329
+ **Example:**
330
+
331
+ ```js
332
+ // Prints "hello"
333
+ consola.log({ message: "hello" });
334
+
335
+ // Prints "{ message: 'hello' }"
336
+ consola.log.raw({ message: "hello" });
337
+ ```
338
+
339
+ ## License
340
+
341
+ MIT
342
+
343
+ <!-- Badges -->
344
+
345
+ [npm-version-src]: https://img.shields.io/npm/v/consola?style=flat&colorA=18181B&colorB=F0DB4F
346
+ [npm-version-href]: https://npmjs.com/package/consola
347
+ [npm-downloads-src]: https://img.shields.io/npm/dm/consola?style=flat&colorA=18181B&colorB=F0DB4F
348
+ [npm-downloads-href]: https://npmjs.com/package/consola
349
+ [codecov-src]: https://img.shields.io/codecov/c/gh/unjs/consola/main?style=flat&colorA=18181B&colorB=F0DB4F
350
+ [codecov-href]: https://codecov.io/gh/unjs/consola
351
+ [bundle-src]: https://img.shields.io/bundlephobia/min/consola?style=flat&colorA=18181B&colorB=F0DB4F
352
+ [bundle-href]: https://bundlephobia.com/result?p=consola
@@ -0,0 +1 @@
1
+ export * from "./dist/basic";
@@ -0,0 +1 @@
1
+ export * from "./dist/browser";
@@ -0,0 +1 @@
1
+ export * from "./dist/core";
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const core = require('./core.cjs');
6
+ const basic = require('./shared/consola.DCGIlDNP.cjs');
7
+ require('node:util');
8
+ require('node:path');
9
+
10
+ function createConsola(options = {}) {
11
+ let level = core.LogLevels.info;
12
+ if (process.env.CONSOLA_LEVEL) {
13
+ level = Number.parseInt(process.env.CONSOLA_LEVEL) ?? level;
14
+ }
15
+ const consola2 = core.createConsola({
16
+ level,
17
+ defaults: { level },
18
+ stdout: process.stdout,
19
+ stderr: process.stderr,
20
+ reporters: options.reporters || [new basic.BasicReporter()],
21
+ ...options
22
+ });
23
+ return consola2;
24
+ }
25
+ const consola = createConsola();
26
+
27
+ exports.Consola = core.Consola;
28
+ exports.LogLevels = core.LogLevels;
29
+ exports.LogTypes = core.LogTypes;
30
+ exports.consola = consola;
31
+ exports.createConsola = createConsola;
32
+ exports.default = consola;
@@ -0,0 +1,23 @@
1
+ import { ConsolaInstance, ConsolaOptions } from './core.cjs';
2
+ export { ConfirmPromptOptions, Consola, ConsolaReporter, FormatOptions, InputLogObject, LogLevel, LogLevels, LogObject, LogType, LogTypes, MultiSelectOptions, PromptOptions, SelectPromptOptions, TextPromptOptions } from './core.cjs';
3
+
4
+ /**
5
+ * Factory function to create a new Consola instance
6
+ *
7
+ * @param {Partial<ConsolaOptions & { fancy: boolean }>} [options={}] - Optional configuration options. See {@link ConsolaOptions}.
8
+ * @returns {ConsolaInstance} A new Consola instance configured with the given options.
9
+ */
10
+ declare function createConsola(options?: Partial<ConsolaOptions & {
11
+ fancy: boolean;
12
+ }>): ConsolaInstance;
13
+ /**
14
+ * Creates and exports a standard instance of Consola with the default configuration.
15
+ * This instance can be used directly for logging throughout the application.
16
+ *
17
+ * @type {ConsolaInstance} consola - The default instance of Consola.
18
+ */
19
+ declare const consola: ConsolaInstance;
20
+
21
+ // @ts-ignore
22
+ export = consola;
23
+ export { ConsolaInstance, ConsolaOptions, consola, createConsola };
@@ -0,0 +1,21 @@
1
+ import { ConsolaInstance, ConsolaOptions } from './core.mjs';
2
+ export { ConfirmPromptOptions, Consola, ConsolaReporter, FormatOptions, InputLogObject, LogLevel, LogLevels, LogObject, LogType, LogTypes, MultiSelectOptions, PromptOptions, SelectPromptOptions, TextPromptOptions } from './core.mjs';
3
+
4
+ /**
5
+ * Factory function to create a new Consola instance
6
+ *
7
+ * @param {Partial<ConsolaOptions & { fancy: boolean }>} [options={}] - Optional configuration options. See {@link ConsolaOptions}.
8
+ * @returns {ConsolaInstance} A new Consola instance configured with the given options.
9
+ */
10
+ declare function createConsola(options?: Partial<ConsolaOptions & {
11
+ fancy: boolean;
12
+ }>): ConsolaInstance;
13
+ /**
14
+ * Creates and exports a standard instance of Consola with the default configuration.
15
+ * This instance can be used directly for logging throughout the application.
16
+ *
17
+ * @type {ConsolaInstance} consola - The default instance of Consola.
18
+ */
19
+ declare const consola: ConsolaInstance;
20
+
21
+ export { ConsolaInstance, ConsolaOptions, consola, createConsola, consola as default };
@@ -0,0 +1,23 @@
1
+ import { ConsolaInstance, ConsolaOptions } from './core.js';
2
+ export { ConfirmPromptOptions, Consola, ConsolaReporter, FormatOptions, InputLogObject, LogLevel, LogLevels, LogObject, LogType, LogTypes, MultiSelectOptions, PromptOptions, SelectPromptOptions, TextPromptOptions } from './core.js';
3
+
4
+ /**
5
+ * Factory function to create a new Consola instance
6
+ *
7
+ * @param {Partial<ConsolaOptions & { fancy: boolean }>} [options={}] - Optional configuration options. See {@link ConsolaOptions}.
8
+ * @returns {ConsolaInstance} A new Consola instance configured with the given options.
9
+ */
10
+ declare function createConsola(options?: Partial<ConsolaOptions & {
11
+ fancy: boolean;
12
+ }>): ConsolaInstance;
13
+ /**
14
+ * Creates and exports a standard instance of Consola with the default configuration.
15
+ * This instance can be used directly for logging throughout the application.
16
+ *
17
+ * @type {ConsolaInstance} consola - The default instance of Consola.
18
+ */
19
+ declare const consola: ConsolaInstance;
20
+
21
+ // @ts-ignore
22
+ export = consola;
23
+ export { ConsolaInstance, ConsolaOptions, consola, createConsola };
@@ -0,0 +1,24 @@
1
+ import { LogLevels, createConsola as createConsola$1 } from './core.mjs';
2
+ export { Consola, LogTypes } from './core.mjs';
3
+ import { B as BasicReporter } from './shared/consola.DRwqZj3T.mjs';
4
+ import 'node:util';
5
+ import 'node:path';
6
+
7
+ function createConsola(options = {}) {
8
+ let level = LogLevels.info;
9
+ if (process.env.CONSOLA_LEVEL) {
10
+ level = Number.parseInt(process.env.CONSOLA_LEVEL) ?? level;
11
+ }
12
+ const consola2 = createConsola$1({
13
+ level,
14
+ defaults: { level },
15
+ stdout: process.stdout,
16
+ stderr: process.stderr,
17
+ reporters: options.reporters || [new BasicReporter()],
18
+ ...options
19
+ });
20
+ return consola2;
21
+ }
22
+ const consola = createConsola();
23
+
24
+ export { LogLevels, consola, createConsola, consola as default };
@@ -0,0 +1,84 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const core = require('./core.cjs');
6
+
7
+ class BrowserReporter {
8
+ options;
9
+ defaultColor;
10
+ levelColorMap;
11
+ typeColorMap;
12
+ constructor(options) {
13
+ this.options = { ...options };
14
+ this.defaultColor = "#7f8c8d";
15
+ this.levelColorMap = {
16
+ 0: "#c0392b",
17
+ // Red
18
+ 1: "#f39c12",
19
+ // Yellow
20
+ 3: "#00BCD4"
21
+ // Cyan
22
+ };
23
+ this.typeColorMap = {
24
+ success: "#2ecc71"
25
+ // Green
26
+ };
27
+ }
28
+ _getLogFn(level) {
29
+ if (level < 1) {
30
+ return console.__error || console.error;
31
+ }
32
+ if (level === 1) {
33
+ return console.__warn || console.warn;
34
+ }
35
+ return console.__log || console.log;
36
+ }
37
+ log(logObj) {
38
+ const consoleLogFn = this._getLogFn(logObj.level);
39
+ const type = logObj.type === "log" ? "" : logObj.type;
40
+ const tag = logObj.tag || "";
41
+ const color = this.typeColorMap[logObj.type] || this.levelColorMap[logObj.level] || this.defaultColor;
42
+ const style = `
43
+ background: ${color};
44
+ border-radius: 0.5em;
45
+ color: white;
46
+ font-weight: bold;
47
+ padding: 2px 0.5em;
48
+ `;
49
+ const badge = `%c${[tag, type].filter(Boolean).join(":")}`;
50
+ if (typeof logObj.args[0] === "string") {
51
+ consoleLogFn(
52
+ `${badge}%c ${logObj.args[0]}`,
53
+ style,
54
+ // Empty string as style resets to default console style
55
+ "",
56
+ ...logObj.args.slice(1)
57
+ );
58
+ } else {
59
+ consoleLogFn(badge, style, ...logObj.args);
60
+ }
61
+ }
62
+ }
63
+
64
+ function createConsola(options = {}) {
65
+ const consola2 = core.createConsola({
66
+ reporters: options.reporters || [new BrowserReporter({})],
67
+ prompt(message, options2 = {}) {
68
+ if (options2.type === "confirm") {
69
+ return Promise.resolve(confirm(message));
70
+ }
71
+ return Promise.resolve(prompt(message));
72
+ },
73
+ ...options
74
+ });
75
+ return consola2;
76
+ }
77
+ const consola = createConsola();
78
+
79
+ exports.Consola = core.Consola;
80
+ exports.LogLevels = core.LogLevels;
81
+ exports.LogTypes = core.LogTypes;
82
+ exports.consola = consola;
83
+ exports.createConsola = createConsola;
84
+ exports.default = consola;
@@ -0,0 +1,23 @@
1
+ import { ConsolaInstance, ConsolaOptions } from './core.cjs';
2
+ export { ConfirmPromptOptions, Consola, ConsolaReporter, FormatOptions, InputLogObject, LogLevel, LogLevels, LogObject, LogType, LogTypes, MultiSelectOptions, PromptOptions, SelectPromptOptions, TextPromptOptions } from './core.cjs';
3
+
4
+ /**
5
+ * Creates a new Consola instance configured specifically for browser environments.
6
+ * This function sets up default reporters and a prompt method tailored to the browser's dialogue APIs.
7
+ *
8
+ * @param {Partial<ConsolaOptions>} [options={}] - Optional configuration options.
9
+ * The options can override the default reporter and prompt behaviour. See {@link ConsolaOptions}.
10
+ * @returns {ConsolaInstance} A new Consola instance optimised for use in browser environments.
11
+ */
12
+ declare function createConsola(options?: Partial<ConsolaOptions>): ConsolaInstance;
13
+ /**
14
+ * A standard Consola instance created with browser-specific configurations.
15
+ * This instance can be used throughout a browser-based project.
16
+ *
17
+ * @type {ConsolaInstance} consola - The default browser-configured Consola instance.
18
+ */
19
+ declare const consola: ConsolaInstance;
20
+
21
+ // @ts-ignore
22
+ export = consola;
23
+ export { ConsolaInstance, ConsolaOptions, consola, createConsola };