@flyingrobots/bijou-node 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Flying Robots
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.
package/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # @flyingrobots/bijou-node
2
+
3
+ Node.js adapter for bijou — chalk styling, readline I/O, process runtime.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @flyingrobots/bijou @flyingrobots/bijou-node
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { initDefaultContext } from '@flyingrobots/bijou-node';
15
+ import { box, headerBox } from '@flyingrobots/bijou';
16
+
17
+ // Wire up Node.js adapters and set the default context.
18
+ // Auto-detects TTY, CI, NO_COLOR, and TERM=dumb.
19
+ initDefaultContext();
20
+
21
+ console.log(headerBox('My CLI', { detail: 'v1.0.0' }));
22
+ ```
23
+
24
+ ## What It Provides
25
+
26
+ `bijou-node` implements the three ports that `@flyingrobots/bijou` requires:
27
+
28
+ | Port | Implementation | What it does |
29
+ | :--- | :--- | :--- |
30
+ | `RuntimePort` | `nodeRuntime()` | `process.env`, `setTimeout`, exit handling |
31
+ | `IOPort` | `nodeIO()` | `process.stdout/stdin`, readline |
32
+ | `StylePort` | `chalkStyle()` | RGB/hex color via chalk, respects `NO_COLOR` |
33
+
34
+ ### API
35
+
36
+ ```typescript
37
+ // Individual port factories
38
+ import { nodeRuntime, nodeIO, chalkStyle } from '@flyingrobots/bijou-node';
39
+
40
+ // All-in-one context (most common)
41
+ import { createNodeContext, initDefaultContext } from '@flyingrobots/bijou-node';
42
+
43
+ // createNodeContext() — returns a BijouContext without setting it as default
44
+ const ctx = createNodeContext();
45
+
46
+ // initDefaultContext() — creates context AND registers it as the global default
47
+ initDefaultContext();
48
+ ```
49
+
50
+ ## Related Packages
51
+
52
+ - [`@flyingrobots/bijou`](https://www.npmjs.com/package/@flyingrobots/bijou) — Zero-dependency core with all components and theme engine
53
+ - [`@flyingrobots/bijou-tui`](https://www.npmjs.com/package/@flyingrobots/bijou-tui) — TEA runtime for interactive terminal apps
54
+
55
+ ## License
56
+
57
+ MIT
@@ -0,0 +1,8 @@
1
+ import type { BijouContext } from '@flyingrobots/bijou';
2
+ export { nodeRuntime } from './runtime.js';
3
+ export { nodeIO } from './io.js';
4
+ export { chalkStyle } from './style.js';
5
+ export declare function createNodeContext(): BijouContext;
6
+ export declare function _resetInitializedForTesting(): void;
7
+ export declare function initDefaultContext(): BijouContext;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAMxD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,wBAAgB,iBAAiB,IAAI,YAAY,CAQhD;AAGD,wBAAgB,2BAA2B,IAAI,IAAI,CAElD;AACD,wBAAgB,kBAAkB,IAAI,YAAY,CAQjD"}
package/dist/index.js ADDED
@@ -0,0 +1,30 @@
1
+ import { createBijou, setDefaultContext } from '@flyingrobots/bijou';
2
+ import { nodeRuntime } from './runtime.js';
3
+ import { nodeIO } from './io.js';
4
+ import { chalkStyle } from './style.js';
5
+ export { nodeRuntime } from './runtime.js';
6
+ export { nodeIO } from './io.js';
7
+ export { chalkStyle } from './style.js';
8
+ export function createNodeContext() {
9
+ const runtime = nodeRuntime();
10
+ const noColor = runtime.env('NO_COLOR') !== undefined;
11
+ return createBijou({
12
+ runtime,
13
+ io: nodeIO(),
14
+ style: chalkStyle(noColor),
15
+ });
16
+ }
17
+ let initialized = false;
18
+ export function _resetInitializedForTesting() {
19
+ initialized = false;
20
+ }
21
+ export function initDefaultContext() {
22
+ if (!initialized) {
23
+ const ctx = createNodeContext();
24
+ setDefaultContext(ctx);
25
+ initialized = true;
26
+ return ctx;
27
+ }
28
+ return createNodeContext();
29
+ }
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,UAAU,iBAAiB;IAC/B,MAAM,OAAO,GAAG,WAAW,EAAE,CAAC;IAC9B,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,SAAS,CAAC;IACtD,OAAO,WAAW,CAAC;QACjB,OAAO;QACP,EAAE,EAAE,MAAM,EAAE;QACZ,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC;KAC3B,CAAC,CAAC;AACL,CAAC;AAED,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB,MAAM,UAAU,2BAA2B;IACzC,WAAW,GAAG,KAAK,CAAC;AACtB,CAAC;AACD,MAAM,UAAU,kBAAkB;IAChC,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,GAAG,GAAG,iBAAiB,EAAE,CAAC;QAChC,iBAAiB,CAAC,GAAG,CAAC,CAAC;QACvB,WAAW,GAAG,IAAI,CAAC;QACnB,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,iBAAiB,EAAE,CAAC;AAC7B,CAAC"}
package/dist/io.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import type { IOPort } from '@flyingrobots/bijou';
2
+ export declare function nodeIO(): IOPort;
3
+ //# sourceMappingURL=io.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"io.d.ts","sourceRoot":"","sources":["../src/io.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAA+B,MAAM,qBAAqB,CAAC;AAE/E,wBAAgB,MAAM,IAAI,MAAM,CAwD/B"}
package/dist/io.js ADDED
@@ -0,0 +1,55 @@
1
+ import * as readline from 'readline';
2
+ import { readFileSync, readdirSync } from 'fs';
3
+ import { join } from 'path';
4
+ export function nodeIO() {
5
+ return {
6
+ write(data) {
7
+ process.stdout.write(data);
8
+ },
9
+ question(prompt) {
10
+ const rl = readline.createInterface({
11
+ input: process.stdin,
12
+ output: process.stdout,
13
+ });
14
+ return new Promise((resolve) => {
15
+ rl.question(prompt, (answer) => {
16
+ rl.close();
17
+ resolve(answer);
18
+ });
19
+ });
20
+ },
21
+ rawInput(onKey) {
22
+ process.stdin.setRawMode(true);
23
+ process.stdin.resume();
24
+ const handler = (data) => {
25
+ onKey(data.toString());
26
+ };
27
+ process.stdin.on('data', handler);
28
+ return {
29
+ dispose() {
30
+ process.stdin.removeListener('data', handler);
31
+ process.stdin.setRawMode(false);
32
+ process.stdin.pause();
33
+ },
34
+ };
35
+ },
36
+ setInterval(callback, ms) {
37
+ const id = globalThis.setInterval(callback, ms);
38
+ return {
39
+ dispose() {
40
+ clearInterval(id);
41
+ },
42
+ };
43
+ },
44
+ readFile(path) {
45
+ return readFileSync(path, 'utf8');
46
+ },
47
+ readDir(path) {
48
+ return readdirSync(path);
49
+ },
50
+ joinPath(...segments) {
51
+ return join(...segments);
52
+ },
53
+ };
54
+ }
55
+ //# sourceMappingURL=io.js.map
package/dist/io.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"io.js","sourceRoot":"","sources":["../src/io.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG5B,MAAM,UAAU,MAAM;IACpB,OAAO;QACL,KAAK,CAAC,IAAY;YAChB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;QAED,QAAQ,CAAC,MAAc;YACrB,MAAM,EAAE,GAAG,QAAQ,CAAC,eAAe,CAAC;gBAClC,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,MAAM,EAAE,OAAO,CAAC,MAAM;aACvB,CAAC,CAAC;YACH,OAAO,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,EAAE;gBACrC,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,CA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@ -0,0 +1,3 @@
1
+ import type { RuntimePort } from '@flyingrobots/bijou';
2
+ export declare function nodeRuntime(): RuntimePort;
3
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,wBAAgB,WAAW,IAAI,WAAW,CAkBzC"}
@@ -0,0 +1,20 @@
1
+ export function nodeRuntime() {
2
+ return {
3
+ env(key) {
4
+ return process.env[key];
5
+ },
6
+ get stdoutIsTTY() {
7
+ return process.stdout.isTTY ?? false;
8
+ },
9
+ get stdinIsTTY() {
10
+ return process.stdin.isTTY ?? false;
11
+ },
12
+ get columns() {
13
+ return process.stdout.columns ?? 80;
14
+ },
15
+ get rows() {
16
+ return process.stdout.rows ?? 24;
17
+ },
18
+ };
19
+ }
20
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,WAAW;IACzB,OAAO;QACL,GAAG,CAAC,GAAW;YACb,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;QACD,IAAI,WAAW;YACb,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,KAAK,CAAC;QACvC,CAAC;QACD,IAAI,UAAU;YACZ,OAAO,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC;QACtC,CAAC;QACD,IAAI,OAAO;YACT,OAAO,OAAO,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;QACtC,CAAC;QACD,IAAI,IAAI;YACN,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QACnC,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { StylePort } from '@flyingrobots/bijou';
2
+ export declare function chalkStyle(noColor?: boolean): StylePort;
3
+ //# sourceMappingURL=style.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../src/style.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAc,MAAM,qBAAqB,CAAC;AAEjE,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAyCvD"}
package/dist/style.js ADDED
@@ -0,0 +1,50 @@
1
+ import chalk from 'chalk';
2
+ export function chalkStyle(noColor) {
3
+ const isNoColor = noColor ?? false;
4
+ function applyModifiers(c, modifiers) {
5
+ if (modifiers === undefined)
6
+ return c;
7
+ let result = c;
8
+ for (const mod of modifiers) {
9
+ switch (mod) {
10
+ case 'bold':
11
+ result = result.bold;
12
+ break;
13
+ case 'dim':
14
+ result = result.dim;
15
+ break;
16
+ case 'strikethrough':
17
+ result = result.strikethrough;
18
+ break;
19
+ case 'inverse':
20
+ result = result.inverse;
21
+ break;
22
+ default: {
23
+ const _exhaustive = mod;
24
+ void _exhaustive;
25
+ }
26
+ }
27
+ }
28
+ return result;
29
+ }
30
+ return {
31
+ styled(token, text) {
32
+ const base = isNoColor ? chalk : chalk.hex(token.hex);
33
+ return applyModifiers(base, token.modifiers)(text);
34
+ },
35
+ rgb(r, g, b, text) {
36
+ if (isNoColor)
37
+ return text;
38
+ return chalk.rgb(r, g, b)(text);
39
+ },
40
+ hex(color, text) {
41
+ if (isNoColor)
42
+ return text;
43
+ return chalk.hex(color)(text);
44
+ },
45
+ bold(text) {
46
+ return chalk.bold(text);
47
+ },
48
+ };
49
+ }
50
+ //# sourceMappingURL=style.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.js","sourceRoot":"","sources":["../src/style.ts"],"names":[],"mappings":"AAAA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAGlD,MAAM,UAAU,UAAU,CAAC,OAAiB;IAC1C,MAAM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AE,IAAY;YAC7B,IAAI,SAAS;gBAAE,OAAO,IAAI,CAAC;YAC3B,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;QAChC,CAAC;QAED,IAAI,CAAC,IAAY;YACf,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;KACF,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@flyingrobots/bijou-node",
3
+ "version": "0.1.0",
4
+ "description": "Node.js adapter for bijou — chalk styling, readline I/O, process runtime.",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "default": "./dist/index.js"
13
+ },
14
+ "./package.json": "./package.json"
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "README.md",
19
+ "LICENSE"
20
+ ],
21
+ "scripts": {
22
+ "build": "tsc -b",
23
+ "prepack": "tsc -b",
24
+ "lint": "tsc --noEmit"
25
+ },
26
+ "dependencies": {
27
+ "@flyingrobots/bijou": "0.1.0",
28
+ "chalk": "^5.6.2"
29
+ },
30
+ "devDependencies": {
31
+ "@types/node": "^22.0.0",
32
+ "typescript": "^5.9.3"
33
+ },
34
+ "keywords": [
35
+ "cli",
36
+ "terminal",
37
+ "bijou",
38
+ "node",
39
+ "adapter",
40
+ "chalk"
41
+ ],
42
+ "author": "James Ross <james@flyingrobots.dev>",
43
+ "license": "MIT",
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "git+https://github.com/flyingrobots/bijou.git",
47
+ "directory": "packages/bijou-node"
48
+ },
49
+ "homepage": "https://github.com/flyingrobots/bijou",
50
+ "bugs": "https://github.com/flyingrobots/bijou/issues",
51
+ "engines": {
52
+ "node": ">=18"
53
+ },
54
+ "publishConfig": {
55
+ "access": "public",
56
+ "provenance": true
57
+ }
58
+ }