colorino 0.4.0 → 0.5.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/dist/browser.cjs +1 -2
- package/dist/browser.d.cts +2 -3
- package/dist/browser.d.mts +2 -3
- package/dist/browser.d.ts +2 -3
- package/dist/browser.mjs +1 -2
- package/dist/node.cjs +101 -34
- package/dist/node.d.cts +2 -3
- package/dist/node.d.mts +2 -3
- package/dist/node.d.ts +2 -3
- package/dist/node.mjs +101 -33
- package/dist/shared/colorino.B1MNcUze.d.cts +455 -0
- package/dist/shared/colorino.B1MNcUze.d.mts +455 -0
- package/dist/shared/colorino.B1MNcUze.d.ts +455 -0
- package/dist/shared/colorino.B9WUj1qg.cjs +777 -0
- package/dist/shared/colorino.CsFoITs1.mjs +768 -0
- package/package.json +14 -11
- package/dist/shared/colorino.B16XJPJ-.mjs +0 -281
- package/dist/shared/colorino.BUBv72sF.cjs +0 -287
- package/dist/shared/colorino.ODiKA7Gy.d.cts +0 -89
- package/dist/shared/colorino.ODiKA7Gy.d.mts +0 -89
- package/dist/shared/colorino.ODiKA7Gy.d.ts +0 -89
package/dist/browser.cjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const determineBaseTheme = require('./shared/colorino.
|
|
4
|
-
require('neverthrow');
|
|
3
|
+
const determineBaseTheme = require('./shared/colorino.B9WUj1qg.cjs');
|
|
5
4
|
|
|
6
5
|
class BrowserColorSupportDetector {
|
|
7
6
|
constructor(_window, _navigator, _overrideTheme) {
|
package/dist/browser.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { P as Palette, C as ColorinoOptions, a as Colorino } from './shared/colorino.
|
|
2
|
-
export { L as LogLevel, T as ThemeName } from './shared/colorino.
|
|
3
|
-
import 'neverthrow';
|
|
1
|
+
import { P as Palette, C as ColorinoOptions, a as Colorino } from './shared/colorino.B1MNcUze.cjs';
|
|
2
|
+
export { L as LogLevel, T as ThemeName } from './shared/colorino.B1MNcUze.cjs';
|
|
4
3
|
|
|
5
4
|
declare function createColorino(palette?: Partial<Palette>, options?: ColorinoOptions): Colorino;
|
|
6
5
|
|
package/dist/browser.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { P as Palette, C as ColorinoOptions, a as Colorino } from './shared/colorino.
|
|
2
|
-
export { L as LogLevel, T as ThemeName } from './shared/colorino.
|
|
3
|
-
import 'neverthrow';
|
|
1
|
+
import { P as Palette, C as ColorinoOptions, a as Colorino } from './shared/colorino.B1MNcUze.mjs';
|
|
2
|
+
export { L as LogLevel, T as ThemeName } from './shared/colorino.B1MNcUze.mjs';
|
|
4
3
|
|
|
5
4
|
declare function createColorino(palette?: Partial<Palette>, options?: ColorinoOptions): Colorino;
|
|
6
5
|
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { P as Palette, C as ColorinoOptions, a as Colorino } from './shared/colorino.
|
|
2
|
-
export { L as LogLevel, T as ThemeName } from './shared/colorino.
|
|
3
|
-
import 'neverthrow';
|
|
1
|
+
import { P as Palette, C as ColorinoOptions, a as Colorino } from './shared/colorino.B1MNcUze.js';
|
|
2
|
+
export { L as LogLevel, T as ThemeName } from './shared/colorino.B1MNcUze.js';
|
|
4
3
|
|
|
5
4
|
declare function createColorino(palette?: Partial<Palette>, options?: ColorinoOptions): Colorino;
|
|
6
5
|
|
package/dist/browser.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { C as ColorLevel, t as themePalettes, a as Colorino, I as InputValidator, d as determineBaseTheme } from './shared/colorino.
|
|
2
|
-
import 'neverthrow';
|
|
1
|
+
import { C as ColorLevel, t as themePalettes, a as Colorino, I as InputValidator, d as determineBaseTheme } from './shared/colorino.CsFoITs1.mjs';
|
|
3
2
|
|
|
4
3
|
class BrowserColorSupportDetector {
|
|
5
4
|
constructor(_window, _navigator, _overrideTheme) {
|
package/dist/node.cjs
CHANGED
|
@@ -1,16 +1,92 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const determineBaseTheme = require('./shared/colorino.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
const determineBaseTheme = require('./shared/colorino.B9WUj1qg.cjs');
|
|
4
|
+
|
|
5
|
+
class OscThemeQuerier {
|
|
6
|
+
constructor(_stdin, _stdout, _timeout = 300, _cacheTtl = 36e5) {
|
|
7
|
+
this._stdin = _stdin;
|
|
8
|
+
this._stdout = _stdout;
|
|
9
|
+
this._timeout = _timeout;
|
|
10
|
+
this._cacheTtl = _cacheTtl;
|
|
11
|
+
}
|
|
12
|
+
_cachedResult;
|
|
13
|
+
_cacheTimestamp;
|
|
14
|
+
query() {
|
|
15
|
+
if (!this._stdout.isTTY || typeof this._stdin.setRawMode !== "function") {
|
|
16
|
+
return determineBaseTheme.err(new determineBaseTheme.OscQueryError("Not a TTY environment"));
|
|
17
|
+
}
|
|
18
|
+
const now = Date.now();
|
|
19
|
+
if (this._cachedResult !== void 0 && this._cacheTimestamp !== void 0 && now - this._cacheTimestamp < this._cacheTtl) {
|
|
20
|
+
return this._cachedResult;
|
|
21
|
+
}
|
|
22
|
+
const result = this._performQuery();
|
|
23
|
+
this._cachedResult = result;
|
|
24
|
+
this._cacheTimestamp = now;
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
_performQuery() {
|
|
28
|
+
const originalRawMode = this._stdin.isRaw;
|
|
29
|
+
let buffer = "";
|
|
30
|
+
this._stdin.setRawMode(true);
|
|
31
|
+
this._stdin.resume();
|
|
32
|
+
this._stdout.write("\x1B]11;?\x1B\\");
|
|
33
|
+
const startTime = Date.now();
|
|
34
|
+
const pollInterval = 10;
|
|
35
|
+
while (Date.now() - startTime < this._timeout) {
|
|
36
|
+
const chunk = this._stdin.read();
|
|
37
|
+
if (chunk !== null) {
|
|
38
|
+
buffer += chunk.toString();
|
|
39
|
+
const parseResult = this._parseResponse(buffer);
|
|
40
|
+
if (parseResult.isOk()) {
|
|
41
|
+
this._cleanup(originalRawMode);
|
|
42
|
+
return parseResult;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
this._sleepSync(pollInterval);
|
|
46
|
+
}
|
|
47
|
+
this._cleanup(originalRawMode);
|
|
48
|
+
return determineBaseTheme.err(
|
|
49
|
+
new determineBaseTheme.OscQueryError("OSC query timeout - terminal did not respond")
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
_cleanup(originalRawMode) {
|
|
53
|
+
this._stdin.setRawMode(originalRawMode);
|
|
54
|
+
this._stdin.pause();
|
|
55
|
+
}
|
|
56
|
+
_sleepSync(ms) {
|
|
57
|
+
const buffer = new SharedArrayBuffer(4);
|
|
58
|
+
const view = new Int32Array(buffer);
|
|
59
|
+
Atomics.wait(view, 0, 0, ms);
|
|
60
|
+
}
|
|
61
|
+
_parseResponse(response) {
|
|
62
|
+
const rgbMatch = response.match(
|
|
63
|
+
/rgb:([0-9a-f]{2,4})\/([0-9a-f]{2,4})\/([0-9a-f]{2,4})/i
|
|
64
|
+
);
|
|
65
|
+
if (!rgbMatch) {
|
|
66
|
+
return determineBaseTheme.err(new determineBaseTheme.OscQueryError("No valid OSC response found in buffer"));
|
|
67
|
+
}
|
|
68
|
+
const red = this._normalizeHex(rgbMatch[1]);
|
|
69
|
+
const green = this._normalizeHex(rgbMatch[2]);
|
|
70
|
+
const blue = this._normalizeHex(rgbMatch[3]);
|
|
71
|
+
const luminance = this._calculateLuminance(red, green, blue);
|
|
72
|
+
return determineBaseTheme.ok(luminance < 0.5 ? "dark" : "light");
|
|
73
|
+
}
|
|
74
|
+
_normalizeHex(hexValue) {
|
|
75
|
+
const normalized = hexValue.padEnd(4, "0").slice(0, 2);
|
|
76
|
+
return parseInt(normalized, 16);
|
|
77
|
+
}
|
|
78
|
+
_calculateLuminance(red, green, blue) {
|
|
79
|
+
return (0.299 * red + 0.587 * green + 0.114 * blue) / 255;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
8
82
|
|
|
9
|
-
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
10
83
|
class NodeColorSupportDetector {
|
|
11
84
|
constructor(_process, overrideTheme) {
|
|
12
85
|
this._process = _process;
|
|
13
|
-
if (!this.isNodeEnv())
|
|
86
|
+
if (!this.isNodeEnv()) {
|
|
87
|
+
this._theme = "unknown";
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
14
90
|
const processEnv = _process.env;
|
|
15
91
|
this._envForceColor = processEnv["FORCE_COLOR"];
|
|
16
92
|
this._envNoColor = processEnv["NO_COLOR"];
|
|
@@ -20,7 +96,20 @@ class NodeColorSupportDetector {
|
|
|
20
96
|
this._envCliColorForce = processEnv["CLICOLOR_FORCE"];
|
|
21
97
|
this._envWtSession = processEnv["WT_SESSION"];
|
|
22
98
|
this._isTTY = !!_process.stdout.isTTY;
|
|
23
|
-
|
|
99
|
+
if (overrideTheme !== void 0) {
|
|
100
|
+
this._theme = overrideTheme;
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (!this._isTTY) {
|
|
104
|
+
this._theme = "unknown";
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const querier = new OscThemeQuerier(
|
|
108
|
+
_process.stdin,
|
|
109
|
+
_process.stdout
|
|
110
|
+
);
|
|
111
|
+
const result = querier.query();
|
|
112
|
+
this._theme = result.isOk() ? result.value : "unknown";
|
|
24
113
|
}
|
|
25
114
|
_envForceColor;
|
|
26
115
|
_envTerm;
|
|
@@ -30,10 +119,13 @@ class NodeColorSupportDetector {
|
|
|
30
119
|
_envCliColorForce;
|
|
31
120
|
_envWtSession;
|
|
32
121
|
_isTTY;
|
|
33
|
-
|
|
122
|
+
_theme;
|
|
34
123
|
isNodeEnv() {
|
|
35
124
|
return typeof this._process !== "undefined";
|
|
36
125
|
}
|
|
126
|
+
getTheme() {
|
|
127
|
+
return this._theme;
|
|
128
|
+
}
|
|
37
129
|
getColorLevel() {
|
|
38
130
|
if (this._envNoColor !== void 0) {
|
|
39
131
|
return determineBaseTheme.ColorLevel.NO_COLOR;
|
|
@@ -85,31 +177,6 @@ class NodeColorSupportDetector {
|
|
|
85
177
|
}
|
|
86
178
|
return this._isTTY || isForced ? determineBaseTheme.ColorLevel.ANSI : determineBaseTheme.ColorLevel.NO_COLOR;
|
|
87
179
|
}
|
|
88
|
-
getTheme() {
|
|
89
|
-
if (this._overrideTheme) return this._overrideTheme;
|
|
90
|
-
if (!this.isNodeEnv() || !this._isTTY) return "unknown";
|
|
91
|
-
const __dirname = node_path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('node.cjs', document.baseURI).href))));
|
|
92
|
-
const scriptPath = node_path.join(__dirname, "./run-osc-querier.js");
|
|
93
|
-
const spawnResult = neverthrow.Result.fromThrowable(
|
|
94
|
-
() => node_child_process.spawnSync(process.execPath, [scriptPath], {
|
|
95
|
-
stdio: ["inherit", "pipe", "pipe"],
|
|
96
|
-
timeout: 1e3,
|
|
97
|
-
encoding: "utf-8"
|
|
98
|
-
}),
|
|
99
|
-
(error) => error
|
|
100
|
-
)();
|
|
101
|
-
if (spawnResult.isErr()) {
|
|
102
|
-
return "unknown";
|
|
103
|
-
}
|
|
104
|
-
const processOutput = spawnResult.value;
|
|
105
|
-
if (processOutput.status !== 0 || processOutput.error) {
|
|
106
|
-
return "unknown";
|
|
107
|
-
}
|
|
108
|
-
const output = processOutput.stdout?.trim();
|
|
109
|
-
if (output === "dark") return "dark";
|
|
110
|
-
if (output === "light") return "light";
|
|
111
|
-
return "unknown";
|
|
112
|
-
}
|
|
113
180
|
}
|
|
114
181
|
|
|
115
182
|
function createColorino(palette = {}, options = {}) {
|
package/dist/node.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { P as Palette, C as ColorinoOptions, a as Colorino } from './shared/colorino.
|
|
2
|
-
export { L as LogLevel, T as ThemeName } from './shared/colorino.
|
|
3
|
-
import 'neverthrow';
|
|
1
|
+
import { P as Palette, C as ColorinoOptions, a as Colorino } from './shared/colorino.B1MNcUze.cjs';
|
|
2
|
+
export { L as LogLevel, T as ThemeName } from './shared/colorino.B1MNcUze.cjs';
|
|
4
3
|
|
|
5
4
|
declare function createColorino(palette?: Partial<Palette>, options?: ColorinoOptions): Colorino;
|
|
6
5
|
|
package/dist/node.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { P as Palette, C as ColorinoOptions, a as Colorino } from './shared/colorino.
|
|
2
|
-
export { L as LogLevel, T as ThemeName } from './shared/colorino.
|
|
3
|
-
import 'neverthrow';
|
|
1
|
+
import { P as Palette, C as ColorinoOptions, a as Colorino } from './shared/colorino.B1MNcUze.mjs';
|
|
2
|
+
export { L as LogLevel, T as ThemeName } from './shared/colorino.B1MNcUze.mjs';
|
|
4
3
|
|
|
5
4
|
declare function createColorino(palette?: Partial<Palette>, options?: ColorinoOptions): Colorino;
|
|
6
5
|
|
package/dist/node.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { P as Palette, C as ColorinoOptions, a as Colorino } from './shared/colorino.
|
|
2
|
-
export { L as LogLevel, T as ThemeName } from './shared/colorino.
|
|
3
|
-
import 'neverthrow';
|
|
1
|
+
import { P as Palette, C as ColorinoOptions, a as Colorino } from './shared/colorino.B1MNcUze.js';
|
|
2
|
+
export { L as LogLevel, T as ThemeName } from './shared/colorino.B1MNcUze.js';
|
|
4
3
|
|
|
5
4
|
declare function createColorino(palette?: Partial<Palette>, options?: ColorinoOptions): Colorino;
|
|
6
5
|
|
package/dist/node.mjs
CHANGED
|
@@ -1,13 +1,90 @@
|
|
|
1
|
-
import { C as ColorLevel, d as determineBaseTheme, t as themePalettes, a as Colorino, I as InputValidator } from './shared/colorino.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { e as err, O as OscQueryError, o as ok, C as ColorLevel, d as determineBaseTheme, t as themePalettes, a as Colorino, I as InputValidator } from './shared/colorino.CsFoITs1.mjs';
|
|
2
|
+
|
|
3
|
+
class OscThemeQuerier {
|
|
4
|
+
constructor(_stdin, _stdout, _timeout = 300, _cacheTtl = 36e5) {
|
|
5
|
+
this._stdin = _stdin;
|
|
6
|
+
this._stdout = _stdout;
|
|
7
|
+
this._timeout = _timeout;
|
|
8
|
+
this._cacheTtl = _cacheTtl;
|
|
9
|
+
}
|
|
10
|
+
_cachedResult;
|
|
11
|
+
_cacheTimestamp;
|
|
12
|
+
query() {
|
|
13
|
+
if (!this._stdout.isTTY || typeof this._stdin.setRawMode !== "function") {
|
|
14
|
+
return err(new OscQueryError("Not a TTY environment"));
|
|
15
|
+
}
|
|
16
|
+
const now = Date.now();
|
|
17
|
+
if (this._cachedResult !== void 0 && this._cacheTimestamp !== void 0 && now - this._cacheTimestamp < this._cacheTtl) {
|
|
18
|
+
return this._cachedResult;
|
|
19
|
+
}
|
|
20
|
+
const result = this._performQuery();
|
|
21
|
+
this._cachedResult = result;
|
|
22
|
+
this._cacheTimestamp = now;
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
_performQuery() {
|
|
26
|
+
const originalRawMode = this._stdin.isRaw;
|
|
27
|
+
let buffer = "";
|
|
28
|
+
this._stdin.setRawMode(true);
|
|
29
|
+
this._stdin.resume();
|
|
30
|
+
this._stdout.write("\x1B]11;?\x1B\\");
|
|
31
|
+
const startTime = Date.now();
|
|
32
|
+
const pollInterval = 10;
|
|
33
|
+
while (Date.now() - startTime < this._timeout) {
|
|
34
|
+
const chunk = this._stdin.read();
|
|
35
|
+
if (chunk !== null) {
|
|
36
|
+
buffer += chunk.toString();
|
|
37
|
+
const parseResult = this._parseResponse(buffer);
|
|
38
|
+
if (parseResult.isOk()) {
|
|
39
|
+
this._cleanup(originalRawMode);
|
|
40
|
+
return parseResult;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
this._sleepSync(pollInterval);
|
|
44
|
+
}
|
|
45
|
+
this._cleanup(originalRawMode);
|
|
46
|
+
return err(
|
|
47
|
+
new OscQueryError("OSC query timeout - terminal did not respond")
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
_cleanup(originalRawMode) {
|
|
51
|
+
this._stdin.setRawMode(originalRawMode);
|
|
52
|
+
this._stdin.pause();
|
|
53
|
+
}
|
|
54
|
+
_sleepSync(ms) {
|
|
55
|
+
const buffer = new SharedArrayBuffer(4);
|
|
56
|
+
const view = new Int32Array(buffer);
|
|
57
|
+
Atomics.wait(view, 0, 0, ms);
|
|
58
|
+
}
|
|
59
|
+
_parseResponse(response) {
|
|
60
|
+
const rgbMatch = response.match(
|
|
61
|
+
/rgb:([0-9a-f]{2,4})\/([0-9a-f]{2,4})\/([0-9a-f]{2,4})/i
|
|
62
|
+
);
|
|
63
|
+
if (!rgbMatch) {
|
|
64
|
+
return err(new OscQueryError("No valid OSC response found in buffer"));
|
|
65
|
+
}
|
|
66
|
+
const red = this._normalizeHex(rgbMatch[1]);
|
|
67
|
+
const green = this._normalizeHex(rgbMatch[2]);
|
|
68
|
+
const blue = this._normalizeHex(rgbMatch[3]);
|
|
69
|
+
const luminance = this._calculateLuminance(red, green, blue);
|
|
70
|
+
return ok(luminance < 0.5 ? "dark" : "light");
|
|
71
|
+
}
|
|
72
|
+
_normalizeHex(hexValue) {
|
|
73
|
+
const normalized = hexValue.padEnd(4, "0").slice(0, 2);
|
|
74
|
+
return parseInt(normalized, 16);
|
|
75
|
+
}
|
|
76
|
+
_calculateLuminance(red, green, blue) {
|
|
77
|
+
return (0.299 * red + 0.587 * green + 0.114 * blue) / 255;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
6
80
|
|
|
7
81
|
class NodeColorSupportDetector {
|
|
8
82
|
constructor(_process, overrideTheme) {
|
|
9
83
|
this._process = _process;
|
|
10
|
-
if (!this.isNodeEnv())
|
|
84
|
+
if (!this.isNodeEnv()) {
|
|
85
|
+
this._theme = "unknown";
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
11
88
|
const processEnv = _process.env;
|
|
12
89
|
this._envForceColor = processEnv["FORCE_COLOR"];
|
|
13
90
|
this._envNoColor = processEnv["NO_COLOR"];
|
|
@@ -17,7 +94,20 @@ class NodeColorSupportDetector {
|
|
|
17
94
|
this._envCliColorForce = processEnv["CLICOLOR_FORCE"];
|
|
18
95
|
this._envWtSession = processEnv["WT_SESSION"];
|
|
19
96
|
this._isTTY = !!_process.stdout.isTTY;
|
|
20
|
-
|
|
97
|
+
if (overrideTheme !== void 0) {
|
|
98
|
+
this._theme = overrideTheme;
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (!this._isTTY) {
|
|
102
|
+
this._theme = "unknown";
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const querier = new OscThemeQuerier(
|
|
106
|
+
_process.stdin,
|
|
107
|
+
_process.stdout
|
|
108
|
+
);
|
|
109
|
+
const result = querier.query();
|
|
110
|
+
this._theme = result.isOk() ? result.value : "unknown";
|
|
21
111
|
}
|
|
22
112
|
_envForceColor;
|
|
23
113
|
_envTerm;
|
|
@@ -27,10 +117,13 @@ class NodeColorSupportDetector {
|
|
|
27
117
|
_envCliColorForce;
|
|
28
118
|
_envWtSession;
|
|
29
119
|
_isTTY;
|
|
30
|
-
|
|
120
|
+
_theme;
|
|
31
121
|
isNodeEnv() {
|
|
32
122
|
return typeof this._process !== "undefined";
|
|
33
123
|
}
|
|
124
|
+
getTheme() {
|
|
125
|
+
return this._theme;
|
|
126
|
+
}
|
|
34
127
|
getColorLevel() {
|
|
35
128
|
if (this._envNoColor !== void 0) {
|
|
36
129
|
return ColorLevel.NO_COLOR;
|
|
@@ -82,31 +175,6 @@ class NodeColorSupportDetector {
|
|
|
82
175
|
}
|
|
83
176
|
return this._isTTY || isForced ? ColorLevel.ANSI : ColorLevel.NO_COLOR;
|
|
84
177
|
}
|
|
85
|
-
getTheme() {
|
|
86
|
-
if (this._overrideTheme) return this._overrideTheme;
|
|
87
|
-
if (!this.isNodeEnv() || !this._isTTY) return "unknown";
|
|
88
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
89
|
-
const scriptPath = join(__dirname, "./run-osc-querier.js");
|
|
90
|
-
const spawnResult = Result.fromThrowable(
|
|
91
|
-
() => spawnSync(process.execPath, [scriptPath], {
|
|
92
|
-
stdio: ["inherit", "pipe", "pipe"],
|
|
93
|
-
timeout: 1e3,
|
|
94
|
-
encoding: "utf-8"
|
|
95
|
-
}),
|
|
96
|
-
(error) => error
|
|
97
|
-
)();
|
|
98
|
-
if (spawnResult.isErr()) {
|
|
99
|
-
return "unknown";
|
|
100
|
-
}
|
|
101
|
-
const processOutput = spawnResult.value;
|
|
102
|
-
if (processOutput.status !== 0 || processOutput.error) {
|
|
103
|
-
return "unknown";
|
|
104
|
-
}
|
|
105
|
-
const output = processOutput.stdout?.trim();
|
|
106
|
-
if (output === "dark") return "dark";
|
|
107
|
-
if (output === "light") return "light";
|
|
108
|
-
return "unknown";
|
|
109
|
-
}
|
|
110
178
|
}
|
|
111
179
|
|
|
112
180
|
function createColorino(palette = {}, options = {}) {
|