@moku-labs/common 0.1.1 → 0.2.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/README.md +2 -0
- package/dist/browser.d.mts +6 -0
- package/dist/browser.mjs +13 -0
- package/dist/cli.cjs +669 -0
- package/dist/cli.d.cts +517 -0
- package/dist/cli.d.mts +517 -0
- package/dist/cli.mjs +652 -0
- package/dist/index.cjs +13 -0
- package/dist/index.d.cts +6 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.mjs +13 -0
- package/package.json +22 -4
package/README.md
CHANGED
|
@@ -53,6 +53,7 @@ bun add @moku-labs/common @moku-labs/core
|
|
|
53
53
|
| [`envPlugin`](src/plugins/env/README.md) | core plugin | Multi-provider environment / secret injection, validated and frozen at `onInit`, with `PUBLIC_` cross-validation. Exposed as `ctx.env`. |
|
|
54
54
|
| `dotenv` · `processEnv` · `cloudflareBindings` | env providers (Node) | Resolve env from `.env` files / `process.env` / Cloudflare bindings. Import `node:fs`. |
|
|
55
55
|
| `browserEnv` | env provider (browser) | Reads `import.meta.env` + `globalThis.__ENV__`. Zero `node:*`. |
|
|
56
|
+
| [`createBrandConsole` · `createBrandPrompts` · `brandedSink`](src/cli/README.md) | CLI kit (Node) | The family's branded terminal renderer — console / prompts / log-sink + ANSI primitives. Imported from `@moku-labs/common/cli`. |
|
|
56
57
|
| `Log` · `Env` | type namespaces | `Log.LogApi`, `Env.EnvConfig`, … |
|
|
57
58
|
|
|
58
59
|
## Usage
|
|
@@ -88,6 +89,7 @@ import { browserEnv } from "@moku-labs/common/browser"; // browser (node-free)
|
|
|
88
89
|
| Entry | Format | For | Includes |
|
|
89
90
|
|---|---|---|---|
|
|
90
91
|
| **`@moku-labs/common`** | dual ESM + CJS | Node | the full catalog, incl. the Node env providers (`dotenv` / `processEnv` / `cloudflareBindings`) |
|
|
92
|
+
| **`@moku-labs/common/cli`** | dual ESM + CJS | Node CLIs | the branded CLI kit — `createBrandConsole`, `createBrandPrompts`, `brandedSink`, and the ANSI primitives |
|
|
91
93
|
| **`@moku-labs/common/browser`** | ESM-only | client bundles | `logPlugin`, `envPlugin`, `browserEnv` and the `Log` / `Env` types — **with all node-only code excluded** |
|
|
92
94
|
|
|
93
95
|
Importing `@moku-labs/common/browser` can **never** drag `node:*` code into a client bundle, regardless of bundler or tree-shaking — its static import graph references zero node-only modules. CI proves it:
|
package/dist/browser.d.mts
CHANGED
|
@@ -137,6 +137,12 @@ type LogApi = {
|
|
|
137
137
|
*/
|
|
138
138
|
addSink(sink: LogSink): void; /** Clear all recorded entries while keeping registered sinks. */
|
|
139
139
|
reset(): void;
|
|
140
|
+
/**
|
|
141
|
+
* Remove all registered output sinks. The in-memory trace (`entries`) is
|
|
142
|
+
* unaffected, so `trace()`/`expect()` keep working — used to replace the default
|
|
143
|
+
* console sink (e.g. a CLI plugin swapping in a branded sink from `@moku-labs/common/cli`).
|
|
144
|
+
*/
|
|
145
|
+
clearSinks(): void;
|
|
140
146
|
};
|
|
141
147
|
//#endregion
|
|
142
148
|
//#region src/plugins/log/index.d.ts
|
package/dist/browser.mjs
CHANGED
|
@@ -393,6 +393,19 @@ function createLogApi(ctx) {
|
|
|
393
393
|
*/
|
|
394
394
|
reset() {
|
|
395
395
|
state.entries.length = 0;
|
|
396
|
+
},
|
|
397
|
+
/**
|
|
398
|
+
* Remove all registered output sinks; the in-memory trace (`entries`) is
|
|
399
|
+
* unaffected, so `trace()`/`expect()` keep working.
|
|
400
|
+
*
|
|
401
|
+
* @example
|
|
402
|
+
* ```ts
|
|
403
|
+
* log.clearSinks();
|
|
404
|
+
* log.addSink(brandedSink()); // from @moku-labs/common/cli
|
|
405
|
+
* ```
|
|
406
|
+
*/
|
|
407
|
+
clearSinks() {
|
|
408
|
+
state.sinks.length = 0;
|
|
396
409
|
}
|
|
397
410
|
};
|
|
398
411
|
}
|