From 293d92bc8ba73bbf125387b927096b2c67a61081 Mon Sep 17 00:00:00 2001 From: clover caruso Date: Sat, 27 Sep 2025 17:28:39 -0700 Subject: [PATCH] chore(lib): term -> log --- lib/jsr.json | 9 ++++++--- lib/{term.ts => log.ts} | 2 +- lib/{term => log}/ansi.ts | 0 lib/{term => log}/headless.ts | 18 +++++++++--------- lib/{term => log}/progress.sample.ts | 0 lib/{term => log}/progress.ts | 4 ++-- lib/readme.md | 8 ++++---- run.js | 22 +++++++++++----------- src/file-viewer/bin/scan3.ts | 6 +++--- src/file-viewer/ffmpeg.ts | 2 +- 10 files changed, 37 insertions(+), 34 deletions(-) rename lib/{term.ts => log.ts} (98%) rename lib/{term => log}/ansi.ts (100%) rename lib/{term => log}/headless.ts (95%) rename lib/{term => log}/progress.sample.ts (100%) rename lib/{term => log}/progress.ts (99%) diff --git a/lib/jsr.json b/lib/jsr.json index 5f7de769bba4746ead3b1c34026628cf6bf79e8f..94c1a1d3e8dfc9b1a84f1afcdfb0b28d19ddfcdc 100644 --- a/lib/jsr.json +++ b/lib/jsr.json @@ -3,8 +3,11 @@ "version": "1.0.0", "license": "MIT", "exports": { - "./term": "./term.ts", - "./term/ansi": "./term/ansi.ts", - "./term/headless": "./term/headless.ts" + "./log": "./log.ts", + "./log/ansi": "./log/ansi.ts", + "./log/headless": "./log/headless.ts", + "./queue": "./queue.ts", + "./string": "./string.ts", + "./ts": "./ts.ts" } } diff --git a/lib/term.ts b/lib/log.ts similarity index 98% rename from lib/term.ts rename to lib/log.ts index 3a9a6c46150ef82d8d0ffd5ba651a9b84be4b9d3..836271096624e18af157bd8da7822abb61cd98b4 100644 --- a/lib/term.ts +++ b/lib/log.ts @@ -98,5 +98,5 @@ const globalLog = /* @__PURE__ */ headless.logger({ }); import process from "node:process"; -import * as headless from "./term/headless.ts"; +import * as headless from "./log/headless.ts"; import * as ts from "./ts.ts"; diff --git a/lib/term/ansi.ts b/lib/log/ansi.ts similarity index 100% rename from lib/term/ansi.ts rename to lib/log/ansi.ts diff --git a/lib/term/headless.ts b/lib/log/headless.ts similarity index 95% rename from lib/term/headless.ts rename to lib/log/headless.ts index 2746f2fa0e106d00e52dd455440687edddf8ec4b..ff30533c15456f31a072519d4aa6403047b81459 100644 --- a/lib/term/headless.ts +++ b/lib/log/headless.ts @@ -42,7 +42,7 @@ export interface WidgetHost { * of the log. this can be used to implement status bars, progress * indicators, and other human i/o. only `format` is required. */ - startWidget(widget: term.Widget): ts.Dispose; + startWidget(widget: log.Widget): ts.Dispose; /** stop all widgets and remove all timers. */ cancel(): void; } @@ -64,7 +64,7 @@ export function widgetHost(env: WidgetHostEnv): WidgetHost { let redrawTime = 0; let lastFlush = 0; let buffer = ""; - const widgets: term.Widget[] = []; + const widgets: log.Widget[] = []; const internals: WidgetState[] = []; let lines: string[] = []; @@ -265,7 +265,7 @@ export interface LoggerOptions { colors: boolean; } -export function logger(env: LoggerOptions): term.Scope { +export function logger(env: LoggerOptions): log.Scope { const { colors, log } = env; const levels = colors ? [ @@ -285,18 +285,18 @@ export function logger(env: LoggerOptions): term.Scope { ); }); - function scoped(name: string): term.Scope { + function scoped(name: string): log.Scope { const formatted = name ? name + colon : name; - const fn = logFn.bind(null, formatted, 0) as Partial; - fn.info = fn as term.Scope["info"]; + const fn = logFn.bind(null, formatted, 0) as Partial; + fn.info = fn as log.Scope["info"]; fn.warn = logFn.bind(null, formatted, 1); fn.error = logFn.bind(null, formatted, 2); fn.scoped = createSubScope; Object.defineProperty(fn, "name", { value: name }); - return fn as term.Scope; + return fn as log.Scope; } - function createSubScope(this: term.Scope, name: string) { + function createSubScope(this: log.Scope, name: string) { const { name: parent } = this; return scoped(parent ? parent + "/" + name : name); } @@ -310,4 +310,4 @@ import * as ansi from "./ansi.ts"; import * as string from "../string.ts"; import * as ts from "../ts.ts"; import * as util from "node:util"; -import type * as term from "../term.ts"; +import type * as log from "../log.ts"; diff --git a/lib/term/progress.sample.ts b/lib/log/progress.sample.ts similarity index 100% rename from lib/term/progress.sample.ts rename to lib/log/progress.sample.ts diff --git a/lib/term/progress.ts b/lib/log/progress.ts similarity index 99% rename from lib/term/progress.ts rename to lib/log/progress.ts index 8482ef81440058ab1107781137ca18f86c268431..349a8e5edea989e16b7145e60c9a3920fc0b5245 100644 --- a/lib/term/progress.ts +++ b/lib/log/progress.ts @@ -340,7 +340,7 @@ function topLevelSignaler(this: State, signal: Signal) { } import * as ts from "../ts.ts"; -import * as log from "../term.ts"; -import * as headless from "../term/headless.ts"; +import * as log from "../log.ts"; +import * as headless from "../log/headless.ts"; import * as ansi from "./ansi.ts"; import * as string from "../string.ts"; diff --git a/lib/readme.md b/lib/readme.md index 886dd37e7eb289bfce107b33e974f6a10d5ab626..f5bb34035f010cc333f79fd303c7da85e2ca7565 100644 --- a/lib/readme.md +++ b/lib/readme.md @@ -19,10 +19,10 @@ the public api is simply all of the code. an overview: - `string` -- `term` - logging, terminal, interactive widgets -- `term/ansi` - cursor and color constants -- `term/headless` - use `term` and `term/progress` without a pty -- `term/progress` - progress bar, spinner, and tree +- `log` - logging, terminal i/o, interactive widgets +- `log/ansi` - cursor and color constants +- `log/headless` - use `log` and `log/progress` without a tty +- `log/progress` - progress bar, spinner, and tree - `ts` typescript types and general purpose code these libraries are published as is, **without versioning or maintainance diff --git a/run.js b/run.js index f74beabb6fa79f25bc3b2cb51ab9ca6914a5687a..8a5f55ec4cdd078395ce6bb2786832489241c71f 100644 --- a/run.js +++ b/run.js @@ -41,17 +41,17 @@ try { // Init hooks const hot = await import("./framework/hot.ts"); -const console = hot.load("@paperclover/console"); -globalThis.console["log"] = console.info; -globalThis.console.info = console.info; -globalThis.console.warn = console.warn; -globalThis.console.error = console.error; -globalThis.console.debug = console.scoped("dbg"); +const log = hot.load("./lib/log.ts"); +console.info = log.info; +console.warn = log.warn; +console.error = log.error; +console.debug = log.scoped("debug"); +console.log = console.debug; // Load with hooks if (process.argv[1].startsWith(import.meta.filename.slice(0, -".js".length))) { if (process.argv.length == 2) { - console.error("usage: node run