@flyingrobots/bijou-node 4.0.0 → 4.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/README.md +4 -4
- package/dist/style.js +27 -12
- package/dist/style.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Node.js adapters and runtime utilities for Bijou.
|
|
4
4
|
|
|
5
|
-
This package bridges the pure `@flyingrobots/bijou` core and the `@flyingrobots/bijou-tui` runtime to the Node.js environment. It owns runtime detection, terminal I/O, Chalk-backed styling, worker-thread helpers, and the native
|
|
5
|
+
This package bridges the pure `@flyingrobots/bijou` core and the `@flyingrobots/bijou-tui` runtime to the Node.js environment. It owns runtime detection, terminal I/O, Chalk-backed styling, worker-thread helpers, and the native surface recorder.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Package Role in v4.0.0
|
|
8
8
|
|
|
9
9
|
- **Worker runtime support** — `runInWorker()` and `startWorkerApp()` let TEA apps move heavy update work off the main thread while keeping input and rendering responsive.
|
|
10
|
-
- **Native
|
|
10
|
+
- **Native surface recorder** — scripted captures can be recorded directly from captured `Surface[]` frames with `recordDemoGif()`.
|
|
11
11
|
- **Node boundary stays explicit** — runtime facts, I/O, and styling remain behind the port interfaces instead of leaking `process`, `readline`, or Chalk into the pure packages.
|
|
12
12
|
|
|
13
13
|
## Install
|
|
@@ -37,7 +37,7 @@ console.log(headerBox('My CLI', { detail: 'v1.0.0' }));
|
|
|
37
37
|
- **Styling backend**: Chalk-powered color/style methods wired into bijou styling APIs.
|
|
38
38
|
- **One-line bootstrap**: `initDefaultContext()` creates a production-ready context and registers it as default on first call.
|
|
39
39
|
- **Worker helpers**: `runInWorker()` and `startWorkerApp()` for moving app logic into a worker thread.
|
|
40
|
-
- **Native recorder**: `recordDemoGif()` and related helpers for scripted
|
|
40
|
+
- **Native recorder**: `recordDemoGif()` and related helpers for scripted surface capture.
|
|
41
41
|
|
|
42
42
|
## What It Provides
|
|
43
43
|
|
package/dist/style.js
CHANGED
|
@@ -8,6 +8,7 @@ export function chalkStyle(arg) {
|
|
|
8
8
|
: chalk;
|
|
9
9
|
/** Whether ANSI styling is active (respects both noColor flag and chalk level). */
|
|
10
10
|
const ansiEnabled = !isNoColor && instance.level > 0;
|
|
11
|
+
const styledCache = new Map();
|
|
11
12
|
/** SGR codes for underline variants (not supported by chalk natively). */
|
|
12
13
|
const UNDERLINE_VARIANT_SGR = {
|
|
13
14
|
'curly-underline': '\x1b[4:3m',
|
|
@@ -72,6 +73,26 @@ export function chalkStyle(arg) {
|
|
|
72
73
|
}
|
|
73
74
|
return result;
|
|
74
75
|
}
|
|
76
|
+
function styleCacheKey(token) {
|
|
77
|
+
return [
|
|
78
|
+
token.hex ?? '',
|
|
79
|
+
token.bg ?? '',
|
|
80
|
+
token.modifiers?.join(',') ?? '',
|
|
81
|
+
].join('|');
|
|
82
|
+
}
|
|
83
|
+
function compileStyled(token) {
|
|
84
|
+
const base = applyModifiers(token.hex ? instance.hex(token.hex) : instance, token.modifiers);
|
|
85
|
+
const background = token.bg ? instance.bgHex(token.bg) : null;
|
|
86
|
+
const modifiers = token.modifiers;
|
|
87
|
+
return (text) => {
|
|
88
|
+
let result = base(text);
|
|
89
|
+
result = applyUnderlineVariants(result, modifiers);
|
|
90
|
+
if (background) {
|
|
91
|
+
result = background(result);
|
|
92
|
+
}
|
|
93
|
+
return result;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
75
96
|
return {
|
|
76
97
|
/**
|
|
77
98
|
* Apply a resolved design-token's hex color and modifiers to text.
|
|
@@ -83,19 +104,13 @@ export function chalkStyle(arg) {
|
|
|
83
104
|
styled(token, text) {
|
|
84
105
|
if (!ansiEnabled)
|
|
85
106
|
return text;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
result = applyUnderlineVariants(result, token.modifiers);
|
|
92
|
-
// Note: bg is applied unconditionally when noColor is false.
|
|
93
|
-
// Callers (e.g. makeBgFill, box, flex) are responsible for
|
|
94
|
-
// stripping token.bg in pipe/accessible/noColor modes.
|
|
95
|
-
if (token.bg) {
|
|
96
|
-
result = instance.bgHex(token.bg)(result);
|
|
107
|
+
const key = styleCacheKey(token);
|
|
108
|
+
let styler = styledCache.get(key);
|
|
109
|
+
if (styler == null) {
|
|
110
|
+
styler = compileStyled(token);
|
|
111
|
+
styledCache.set(key, styler);
|
|
97
112
|
}
|
|
98
|
-
return
|
|
113
|
+
return styler(text);
|
|
99
114
|
},
|
|
100
115
|
/**
|
|
101
116
|
* Apply a 24-bit RGB foreground color to text.
|
package/dist/style.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.js","sourceRoot":"","sources":["../src/style.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,KAAK,EAAsB,MAAM,OAAO,CAAC;AA2BzD,iBAAiB;AACjB,MAAM,UAAU,UAAU,CAAC,GAAiC;IAC1D,MAAM,IAAI,GAAG,OAAO,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC;IACvE,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,IAAI,KAAK,CAAC;IACxC,MAAM,QAAQ,GAAkB,IAAI,CAAC,KAAK,KAAK,SAAS;QACtD,CAAC,CAAC,IAAI,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;QAClC,CAAC,CAAC,KAAK,CAAC;IACV,mFAAmF;IACnF,MAAM,WAAW,GAAG,CAAC,SAAS,IAAI,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"style.js","sourceRoot":"","sources":["../src/style.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,KAAK,EA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AC,CAAC;QACrC,CAAC;QAED;;;;;;WAMG;QACH,GAAG,CAAC,KAAa,EAAE,IAAY;YAC7B,IAAI,SAAS;gBAAE,OAAO,IAAI,CAAC;YAC3B,OAAO,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;QACnC,CAAC;QAED;;;;;;;;WAQG;QACH,KAAK,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,IAAY;YACjD,IAAI,SAAS;gBAAE,OAAO,IAAI,CAAC;YAC3B,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACvC,CAAC;QAED;;;;;;WAMG;QACH,KAAK,CAAC,KAAa,EAAE,IAAY;YAC/B,IAAI,SAAS;gBAAE,OAAO,IAAI,CAAC;YAC3B,OAAO,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;QACrC,CAAC;QAED;;;;;WAKG;QACH,IAAI,CAAC,IAAY;YACf,IAAI,SAAS;gBAAE,OAAO,IAAI,CAAC;YAC3B,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flyingrobots/bijou-node",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Node.js adapter for bijou — chalk styling, readline I/O, process runtime.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
"lint": "tsc --noEmit"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@flyingrobots/bijou-tui": "4.
|
|
27
|
+
"@flyingrobots/bijou-tui": "4.1.0",
|
|
28
28
|
"chalk": "^5.6.2",
|
|
29
29
|
"gifenc": "^1.0.3",
|
|
30
30
|
"oled-font-5x7": "^1.0.3"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@flyingrobots/bijou": "4.
|
|
33
|
+
"@flyingrobots/bijou": "4.1.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "^22.0.0",
|