@redplanethq/corebrain 1.0.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 +44 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +7 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/index.d.ts +14 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +10 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/login.d.ts +8 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +131 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +8 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +52 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/me.d.ts +8 -0
- package/dist/commands/me.d.ts.map +1 -0
- package/dist/commands/me.js +59 -0
- package/dist/commands/me.js.map +1 -0
- package/dist/commands/token.d.ts +8 -0
- package/dist/commands/token.d.ts.map +1 -0
- package/dist/commands/token.js +31 -0
- package/dist/commands/token.js.map +1 -0
- package/dist/components/error-message.d.ts +7 -0
- package/dist/components/error-message.d.ts.map +1 -0
- package/dist/components/error-message.js +12 -0
- package/dist/components/error-message.js.map +1 -0
- package/dist/components/info-message.d.ts +6 -0
- package/dist/components/info-message.d.ts.map +1 -0
- package/dist/components/info-message.js +11 -0
- package/dist/components/info-message.js.map +1 -0
- package/dist/components/success-message.d.ts +6 -0
- package/dist/components/success-message.d.ts.map +1 -0
- package/dist/components/success-message.js +11 -0
- package/dist/components/success-message.js.map +1 -0
- package/dist/components/warning-message.d.ts +7 -0
- package/dist/components/warning-message.d.ts.map +1 -0
- package/dist/components/warning-message.js +12 -0
- package/dist/components/warning-message.js.map +1 -0
- package/dist/config/env-substitution.d.ts +2 -0
- package/dist/config/env-substitution.d.ts.map +1 -0
- package/dist/config/env-substitution.js +43 -0
- package/dist/config/env-substitution.js.map +1 -0
- package/dist/config/index.d.ts +11 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +139 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/paths.d.ts +3 -0
- package/dist/config/paths.d.ts.map +1 -0
- package/dist/config/paths.js +51 -0
- package/dist/config/paths.js.map +1 -0
- package/dist/config/themes.d.ts +10 -0
- package/dist/config/themes.d.ts.map +1 -0
- package/dist/config/themes.js +66 -0
- package/dist/config/themes.js.map +1 -0
- package/dist/hooks/useTerminalWidth.d.ts +18 -0
- package/dist/hooks/useTerminalWidth.d.ts.map +1 -0
- package/dist/hooks/useTerminalWidth.js +65 -0
- package/dist/hooks/useTerminalWidth.js.map +1 -0
- package/dist/hooks/useTheme.d.ts +10 -0
- package/dist/hooks/useTheme.d.ts.map +1 -0
- package/dist/hooks/useTheme.js +10 -0
- package/dist/hooks/useTheme.js.map +1 -0
- package/dist/types/config.d.ts +64 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +2 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +4 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/ui.d.ts +19 -0
- package/dist/types/ui.d.ts.map +1 -0
- package/dist/types/ui.js +2 -0
- package/dist/types/ui.js.map +1 -0
- package/dist/types/utils.d.ts +14 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/dist/types/utils.js +2 -0
- package/dist/types/utils.js.map +1 -0
- package/dist/utils/message-queue.d.ts +7 -0
- package/dist/utils/message-queue.d.ts.map +1 -0
- package/dist/utils/message-queue.js +58 -0
- package/dist/utils/message-queue.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { logError } from '../utils/message-queue.js';
|
|
2
|
+
// Expand environment variable references in a string
|
|
3
|
+
function expandEnvVar(str) {
|
|
4
|
+
if (typeof str !== 'string') {
|
|
5
|
+
return str;
|
|
6
|
+
}
|
|
7
|
+
const regex = /\$\{([A-Z_][A-Z0-9_]*)(?::-(.*?))?\}|\$([A-Z_][A-Z0-9_]*)/g;
|
|
8
|
+
return str.replace(regex, (_match, bracedVarName, defaultValue, unbracedVarName) => {
|
|
9
|
+
const varName = bracedVarName || unbracedVarName;
|
|
10
|
+
if (!varName)
|
|
11
|
+
return '';
|
|
12
|
+
const envValue = process.env[varName];
|
|
13
|
+
if (envValue !== undefined) {
|
|
14
|
+
return envValue;
|
|
15
|
+
}
|
|
16
|
+
if (defaultValue !== undefined) {
|
|
17
|
+
return defaultValue;
|
|
18
|
+
}
|
|
19
|
+
logError(`Environment variable ${varName} not found in config, using empty string`);
|
|
20
|
+
return '';
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
// Recursively substitute environment variables in objects, arrays, and strings
|
|
24
|
+
export function substituteEnvVars(value) {
|
|
25
|
+
if (value === null || value === undefined) {
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
if (typeof value === 'string') {
|
|
29
|
+
return expandEnvVar(value);
|
|
30
|
+
}
|
|
31
|
+
if (Array.isArray(value)) {
|
|
32
|
+
return value.map((item) => substituteEnvVars(item));
|
|
33
|
+
}
|
|
34
|
+
if (typeof value === 'object') {
|
|
35
|
+
const result = {};
|
|
36
|
+
for (const [key, val] of Object.entries(value)) {
|
|
37
|
+
result[key] = substituteEnvVars(val);
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=env-substitution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env-substitution.js","sourceRoot":"","sources":["../../src/config/env-substitution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAE/C,qDAAqD;AACrD,SAAS,YAAY,CAAC,GAAW;IAChC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAA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,EAAE,CAAC;YAChD,MAAM,CAAC,GAAG,CAAC,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;QACtC,CAAC;QAED,OAAO,MAAW,CAAC;IACpB,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AppConfig, Colors } from '../types/index.js';
|
|
2
|
+
export declare const confDirMap: Record<string, string>;
|
|
3
|
+
export declare function getClosestConfigFile(fileName: string): string;
|
|
4
|
+
export declare let appConfig: AppConfig;
|
|
5
|
+
export declare function getConfig(): AppConfig;
|
|
6
|
+
export declare function updateConfig(newConfig: Partial<AppConfig>): void;
|
|
7
|
+
export declare function reloadAppConfig(): void;
|
|
8
|
+
export declare function getColors(): Colors;
|
|
9
|
+
export declare const colors: Colors;
|
|
10
|
+
export declare const promptPath: string;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAE,MAAM,EAAC,MAAM,eAAe,CAAC;AAyBrD,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,CAAC;AAGrD,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAmC7D;AA8CD,eAAO,IAAI,SAAS,WAAkB,CAAC;AAGvC,wBAAgB,SAAS,IAAI,SAAS,CAErC;AAGD,wBAAgB,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI,CAsBhE;AAGD,wBAAgB,eAAe,IAAI,IAAI,CAEtC;AAID,wBAAgB,SAAS,IAAI,MAAM,CAMlC;AAGD,eAAO,MAAM,MAAM,QAIjB,CAAC;AAOH,eAAO,MAAM,UAAU,QAGtB,CAAC"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { existsSync, readFileSync, mkdirSync, writeFileSync } from 'fs';
|
|
2
|
+
import { join, dirname } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import { homedir } from 'os';
|
|
5
|
+
import { config as loadEnv } from 'dotenv';
|
|
6
|
+
import { logError } from '../utils/message-queue.js';
|
|
7
|
+
import { getThemeColors, defaultTheme } from '../config/themes.js';
|
|
8
|
+
import { substituteEnvVars } from '../config/env-substitution.js';
|
|
9
|
+
import { getConfigPath } from '../config/paths.js';
|
|
10
|
+
// Load .env file from working directory (shell environment takes precedence)
|
|
11
|
+
// Suppress dotenv console output by temporarily redirecting stdout
|
|
12
|
+
const envPath = join(process.cwd(), '.env');
|
|
13
|
+
if (existsSync(envPath)) {
|
|
14
|
+
const originalWrite = process.stdout.write.bind(process.stdout);
|
|
15
|
+
process.stdout.write = () => true;
|
|
16
|
+
try {
|
|
17
|
+
loadEnv({ path: envPath });
|
|
18
|
+
}
|
|
19
|
+
finally {
|
|
20
|
+
process.stdout.write = originalWrite;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
// Hold a map of what config files are where
|
|
24
|
+
export const confDirMap = {};
|
|
25
|
+
// Find the closest config file for the requested configuration file
|
|
26
|
+
export function getClosestConfigFile(fileName) {
|
|
27
|
+
try {
|
|
28
|
+
const configDir = getConfigPath();
|
|
29
|
+
// First, lets check for a working directory config
|
|
30
|
+
if (existsSync(join(process.cwd(), fileName))) {
|
|
31
|
+
confDirMap[fileName] = join(process.cwd(), fileName);
|
|
32
|
+
return join(process.cwd(), fileName);
|
|
33
|
+
}
|
|
34
|
+
// Next lets check the $HOME for a hidden file. This should only be for
|
|
35
|
+
// legacy support
|
|
36
|
+
if (existsSync(join(homedir(), `.${fileName}`))) {
|
|
37
|
+
confDirMap[fileName] = join(homedir(), `.${fileName}`);
|
|
38
|
+
return join(homedir(), `.${fileName}`);
|
|
39
|
+
}
|
|
40
|
+
// Last, lets look for an user level config.
|
|
41
|
+
// If the file doesn't exist, create it
|
|
42
|
+
if (!existsSync(join(configDir, fileName))) {
|
|
43
|
+
createDefaultConfFile(configDir, fileName);
|
|
44
|
+
}
|
|
45
|
+
confDirMap[fileName] = join(configDir, fileName);
|
|
46
|
+
return join(configDir, fileName);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
logError(`Failed to load ${fileName}: ${String(error)}`);
|
|
50
|
+
}
|
|
51
|
+
// The code should never hit this, but it makes the TS compiler happy.
|
|
52
|
+
return fileName;
|
|
53
|
+
}
|
|
54
|
+
function createDefaultConfFile(filePath, fileName) {
|
|
55
|
+
try {
|
|
56
|
+
// If we cant find any, lets assume this is the first user run, create the
|
|
57
|
+
// correct file and direct the user to configure them correctly,
|
|
58
|
+
if (!existsSync(join(filePath, fileName))) {
|
|
59
|
+
// Maybe add a better sample config?
|
|
60
|
+
const sampleConfig = {};
|
|
61
|
+
mkdirSync(filePath, { recursive: true });
|
|
62
|
+
writeFileSync(join(filePath, fileName), JSON.stringify(sampleConfig, null, 2), 'utf-8');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
logError(`Failed to write ${filePath}: ${String(error)}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// Function to load app configuration from config.json if it exists
|
|
70
|
+
function loadAppConfig() {
|
|
71
|
+
const configJsonPath = getClosestConfigFile('config.json');
|
|
72
|
+
try {
|
|
73
|
+
const rawData = readFileSync(configJsonPath, 'utf-8');
|
|
74
|
+
const configData = JSON.parse(rawData);
|
|
75
|
+
// Apply environment variable substitution
|
|
76
|
+
const processedData = substituteEnvVars(configData);
|
|
77
|
+
if (processedData.core) {
|
|
78
|
+
return {
|
|
79
|
+
auth: processedData.core.auth,
|
|
80
|
+
providers: processedData.core.providers ?? [],
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
//
|
|
86
|
+
}
|
|
87
|
+
return {};
|
|
88
|
+
}
|
|
89
|
+
export let appConfig = loadAppConfig();
|
|
90
|
+
// Function to get current app configuration
|
|
91
|
+
export function getConfig() {
|
|
92
|
+
return appConfig;
|
|
93
|
+
}
|
|
94
|
+
// Function to update app configuration
|
|
95
|
+
export function updateConfig(newConfig) {
|
|
96
|
+
const configJsonPath = getClosestConfigFile('config.json');
|
|
97
|
+
try {
|
|
98
|
+
// Read current config
|
|
99
|
+
const rawData = readFileSync(configJsonPath, 'utf-8');
|
|
100
|
+
const configData = JSON.parse(rawData);
|
|
101
|
+
// Update config
|
|
102
|
+
if (!configData.core) {
|
|
103
|
+
configData.core = {};
|
|
104
|
+
}
|
|
105
|
+
Object.assign(configData.core, newConfig);
|
|
106
|
+
// Write back to file
|
|
107
|
+
writeFileSync(configJsonPath, JSON.stringify(configData, null, 2), 'utf-8');
|
|
108
|
+
// Reload config to update in-memory cache
|
|
109
|
+
reloadAppConfig();
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
console.warn('Failed to update config:', error);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// Function to reload the app configuration (useful after config file changes)
|
|
116
|
+
export function reloadAppConfig() {
|
|
117
|
+
appConfig = loadAppConfig();
|
|
118
|
+
}
|
|
119
|
+
let cachedColors = null;
|
|
120
|
+
export function getColors() {
|
|
121
|
+
if (!cachedColors) {
|
|
122
|
+
const selectedTheme = defaultTheme;
|
|
123
|
+
cachedColors = getThemeColors(selectedTheme);
|
|
124
|
+
}
|
|
125
|
+
return cachedColors;
|
|
126
|
+
}
|
|
127
|
+
// Legacy export for backwards compatibility - use a getter to avoid circular dependency
|
|
128
|
+
export const colors = new Proxy({}, {
|
|
129
|
+
get(_target, prop) {
|
|
130
|
+
return getColors()[prop];
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
// Get the package root directory (where this module is installed)
|
|
134
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
135
|
+
const __dirname = dirname(__filename);
|
|
136
|
+
// Go up from dist/config to package root, then to source/app/prompts/main-prompt.md
|
|
137
|
+
// This works because source/app/prompts/main-prompt.md is included in the package.json files array
|
|
138
|
+
export const promptPath = join(__dirname, '../../source/app/prompts/main-prompt.md');
|
|
139
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAC,MAAM,IAAI,CAAC;AACtE,OAAO,EAAC,IAAI,EAAE,OAAO,EAAC,MAAM,MAAM,CAAC;AACnC,OAAO,EAAC,aAAa,EAAC,MAAM,KAAK,CAAC;AAClC,OAAO,EAAC,OAAO,EAAC,MAAM,IAAI,CAAC;AAC3B,OAAO,EAAC,MAAM,IAAI,OAAO,EAAC,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAC,cAAc,EAAE,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAC,iBAAiB,EAAC,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAE7C,6EAA6E;AAC7E,mEAAmE;AACnE,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,CAAC;AAC5C,IAAI,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;IACzB,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAChE,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC;IAClC,IAAI,CAAC;QACJ,OAAO,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC,CAAC;IAC1B,CAAC;YAAS,CAAC;QACV,OAAO,CA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aAAa,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,YAAY,CAAC;AACrB,CAAC;AAED,wFAAwF;AACxF,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,KAAK,CAAC,EAAY,EAAE;IAC7C,GAAG,CAAC,OAAO,EAAE,IAAI;QAChB,OAAO,SAAS,EAAE,CAAC,IAAoB,CAAC,CAAC;IAC1C,CAAC;CACD,CAAC,CAAC;AAEH,kEAAkE;AAClE,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACtC,oFAAoF;AACpF,mGAAmG;AACnG,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAC7B,SAAS,EACT,yCAAyC,CACzC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/config/paths.ts"],"names":[],"mappings":"AAGA,wBAAgB,cAAc,IAAI,MAAM,CA4BvC;AAED,wBAAgB,aAAa,IAAI,MAAM,CAqBtC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { homedir } from 'os';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
export function getAppDataPath() {
|
|
4
|
+
// Allow explicit override via environment variable
|
|
5
|
+
if (process.env.CORE_DATA_DIR) {
|
|
6
|
+
return process.env.CORE_DATA_DIR;
|
|
7
|
+
}
|
|
8
|
+
// Check XDG_DATA_HOME first (works cross-platform for testing)
|
|
9
|
+
if (process.env.XDG_DATA_HOME) {
|
|
10
|
+
return join(process.env.XDG_DATA_HOME, 'core');
|
|
11
|
+
}
|
|
12
|
+
// Platform-specific app data directories
|
|
13
|
+
let baseAppDataPath;
|
|
14
|
+
switch (process.platform) {
|
|
15
|
+
case 'win32': {
|
|
16
|
+
baseAppDataPath =
|
|
17
|
+
process.env.APPDATA ?? join(homedir(), 'AppData', 'Roaming');
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
case 'darwin': {
|
|
21
|
+
baseAppDataPath = join(homedir(), 'Library', 'Application Support');
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
default: {
|
|
25
|
+
baseAppDataPath = join(homedir(), '.local', 'share');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return join(baseAppDataPath, 'core');
|
|
29
|
+
}
|
|
30
|
+
export function getConfigPath() {
|
|
31
|
+
// Allow explicit override via environment variable
|
|
32
|
+
if (process.env.CORE_CONFIG_DIR) {
|
|
33
|
+
return process.env.CORE_CONFIG_DIR;
|
|
34
|
+
}
|
|
35
|
+
// Platform-specific defaults
|
|
36
|
+
let baseConfigPath;
|
|
37
|
+
switch (process.platform) {
|
|
38
|
+
case 'win32':
|
|
39
|
+
baseConfigPath =
|
|
40
|
+
process.env.APPDATA ?? join(homedir(), 'AppData', 'Roaming');
|
|
41
|
+
break;
|
|
42
|
+
case 'darwin':
|
|
43
|
+
baseConfigPath = join(homedir(), 'Library', 'Preferences');
|
|
44
|
+
break;
|
|
45
|
+
default:
|
|
46
|
+
baseConfigPath =
|
|
47
|
+
process.env.XDG_CONFIG_HOME ?? join(homedir(), '.config');
|
|
48
|
+
}
|
|
49
|
+
return join(baseConfigPath, 'core');
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/config/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,IAAI,CAAC;AAC3B,OAAO,EAAC,IAAI,EAAC,MAAM,MAAM,CAAC;AAE1B,MAAM,UAAU,cAAc;IAC7B,mDAAmD;IACnD,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;QAC/B,OAAO,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;IAClC,CAAC;IAED,+DAA+D;IAC/D,I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,cAAc;gBACb,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Theme, ThemePreset, Colors } from '../types/ui.js';
|
|
2
|
+
/**
|
|
3
|
+
* Detect if terminal is using a light or dark background
|
|
4
|
+
* Uses COLORFGBG environment variable or defaults to dark
|
|
5
|
+
*/
|
|
6
|
+
export declare function detectTerminalTheme(): 'dark' | 'light';
|
|
7
|
+
export declare const themes: Record<ThemePreset, Theme>;
|
|
8
|
+
export declare function getThemeColors(themePreset: ThemePreset): Colors;
|
|
9
|
+
export declare const defaultTheme: ThemePreset;
|
|
10
|
+
//# sourceMappingURL=themes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"themes.d.ts","sourceRoot":"","sources":["../../src/config/themes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAC,MAAM,YAAY,CAAC;AA+B3D;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,GAAG,OAAO,CA4BtD;AAED,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,WAAW,EAAE,KAAK,CAO7C,CAAC;AAEF,wBAAgB,cAAc,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAE/D;AAED,eAAO,MAAM,YAAY,EAAE,WAAoB,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
const darkThemeColors = {
|
|
2
|
+
white: 'white',
|
|
3
|
+
black: 'black',
|
|
4
|
+
primary: '#C15E50',
|
|
5
|
+
muted: 'gray',
|
|
6
|
+
tool: '#C15E50',
|
|
7
|
+
info: '#C15E50',
|
|
8
|
+
// Muted text
|
|
9
|
+
// Status
|
|
10
|
+
success: 'green',
|
|
11
|
+
error: 'red',
|
|
12
|
+
warning: 'yellow',
|
|
13
|
+
secondary: 'cyan', // neutral secondary, readable on both themes
|
|
14
|
+
};
|
|
15
|
+
const lightThemeColors = {
|
|
16
|
+
white: '#1a1a1a',
|
|
17
|
+
black: '#f5f5f5',
|
|
18
|
+
primary: '#B94A3C',
|
|
19
|
+
muted: '#B94A3C',
|
|
20
|
+
tool: '#A83585',
|
|
21
|
+
success: '#2D8659',
|
|
22
|
+
error: '#C13332',
|
|
23
|
+
secondary: '#8B5A25',
|
|
24
|
+
info: '#B94A3C',
|
|
25
|
+
warning: '#C78540',
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Detect if terminal is using a light or dark background
|
|
29
|
+
* Uses COLORFGBG environment variable or defaults to dark
|
|
30
|
+
*/
|
|
31
|
+
export function detectTerminalTheme() {
|
|
32
|
+
// Check COLORFGBG environment variable (format: "foreground;background")
|
|
33
|
+
const colorFgBg = process.env.COLORFGBG;
|
|
34
|
+
if (colorFgBg) {
|
|
35
|
+
const parts = colorFgBg.split(';');
|
|
36
|
+
const bg = parts[parts.length - 1];
|
|
37
|
+
if (bg) {
|
|
38
|
+
const bgNum = parseInt(bg, 10);
|
|
39
|
+
// ANSI colors 0-6 are typically dark, 7-15 are bright/light
|
|
40
|
+
if (!isNaN(bgNum)) {
|
|
41
|
+
return bgNum >= 7 ? 'light' : 'dark';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// Check for common light theme indicators in environment
|
|
46
|
+
const term = process.env.TERM_PROGRAM || '';
|
|
47
|
+
if (process.env.THEME === 'light' ||
|
|
48
|
+
process.env.COLORTERM === 'light' ||
|
|
49
|
+
term.toLowerCase().includes('light')) {
|
|
50
|
+
return 'light';
|
|
51
|
+
}
|
|
52
|
+
// Default to dark theme (most common for developers)
|
|
53
|
+
return 'dark';
|
|
54
|
+
}
|
|
55
|
+
export const themes = {
|
|
56
|
+
main: {
|
|
57
|
+
name: 'main',
|
|
58
|
+
displayName: 'Main',
|
|
59
|
+
colors: detectTerminalTheme() === 'dark' ? darkThemeColors : lightThemeColors,
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
export function getThemeColors(themePreset) {
|
|
63
|
+
return themes[themePreset].colors;
|
|
64
|
+
}
|
|
65
|
+
export const defaultTheme = 'main';
|
|
66
|
+
//# sourceMappingURL=themes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"themes.js","sourceRoot":"","sources":["../../src/config/themes.ts"],"names":[],"mappings":"AAEA,MAAM,eAAe,GAAW;IAC/B,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,MAAM;IACb,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,SAAS;IACf,aAAa;IAEb,SAAS;IACT,OAAO,EAAE,OAAO;IAChB,KAAK,EAAE,KAAK;IACZ,OAAO,EAAE,QAAQ;IACjB,SAAS,EAAE,MAAM,EAAE,6CAA6C;CAChE,CAAC;AAEF,MAAM,gBAAgB,GAAW;IAChC,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,SAAS;IAChB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,SAAS;IAChB,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,SAAS;IAChB,SAAS,EAAE,SAAS;IACpB,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,SAAS;CAClB,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,mBAAmB;IAClC,yEAAyE;IACzE,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;IACxC,IAAI,SAAS,EAAE,CAAC;QACf,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnC,MAAM,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACnC,IAAI,EAAE,EAAE,CAAC;YACR,MAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;YAC/B,4DAA4D;YAC5D,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;gBACnB,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;YACtC,CAAC;QACF,CAAC;IACF,CAAC;IAED,yDAAyD;IACzD,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC;IAE5C,IACC,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,OAAO;QAC7B,OAAO,CAAC,GAAG,CAAC,SAAS,KAAK,OAAO;QACjC,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,EACnC,CAAC;QACF,OAAO,OAAO,CAAC;IAChB,CAAC;IAED,qDAAqD;IACrD,OAAO,MAAM,CAAC;AACf,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAA+B;IACjD,IAAI,EAAE;QACL,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,MAAM;QACnB,MAAM,EACL,mBAAmB,EAAE,KAAK,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,gBAAgB;KACtE;CACD,CAAC;AAEF,MAAM,UAAU,cAAc,CAAC,WAAwB;IACtD,OAAO,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC;AACnC,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAgB,MAAM,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type TerminalSize = 'narrow' | 'normal' | 'wide';
|
|
2
|
+
export declare const useTerminalWidth: () => number;
|
|
3
|
+
/**
|
|
4
|
+
* Hook to detect terminal size category and provide responsive utilities
|
|
5
|
+
* @returns Object with terminal width, size category, and utility functions
|
|
6
|
+
*/
|
|
7
|
+
export declare const useResponsiveTerminal: () => {
|
|
8
|
+
boxWidth: number;
|
|
9
|
+
actualWidth: number;
|
|
10
|
+
size: TerminalSize;
|
|
11
|
+
isNarrow: boolean;
|
|
12
|
+
isNormal: boolean;
|
|
13
|
+
isWide: boolean;
|
|
14
|
+
truncate: (text: string, maxLength: number) => string;
|
|
15
|
+
truncatePath: (pathStr: string, maxLength: number) => string;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=useTerminalWidth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTerminalWidth.d.ts","sourceRoot":"","sources":["../../src/hooks/useTerminalWidth.tsx"],"names":[],"mappings":"AAEA,KAAK,YAAY,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEjD,eAAO,MAAM,gBAAgB,cAgC5B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;;;;qBAcT,MAAM,aAAa,MAAM,KAAG,MAAM;4BAM3B,MAAM,aAAa,MAAM,KAAG,MAAM;CAejE,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
export const useTerminalWidth = () => {
|
|
3
|
+
// Calculate box width (leave some padding and ensure minimum width)
|
|
4
|
+
const calculateBoxWidth = (columns) => Math.max(Math.min(columns - 4, 120), 40);
|
|
5
|
+
const [boxWidth, setBoxWidth] = useState(() => calculateBoxWidth(process.stdout.columns || 80));
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const handleResize = () => {
|
|
8
|
+
const newWidth = calculateBoxWidth(process.stdout.columns || 80);
|
|
9
|
+
// Only update if width actually changed
|
|
10
|
+
setBoxWidth(prevWidth => (prevWidth !== newWidth ? newWidth : prevWidth));
|
|
11
|
+
};
|
|
12
|
+
// Increase max listeners if needed (many components use this hook simultaneously)
|
|
13
|
+
const currentMax = process.stdout.getMaxListeners();
|
|
14
|
+
if (currentMax !== 0 && currentMax < 50) {
|
|
15
|
+
// 0 means unlimited, otherwise ensure we have enough headroom
|
|
16
|
+
process.stdout.setMaxListeners(50);
|
|
17
|
+
}
|
|
18
|
+
// Listen for terminal resize events
|
|
19
|
+
process.stdout.on('resize', handleResize);
|
|
20
|
+
return () => {
|
|
21
|
+
process.stdout.off('resize', handleResize);
|
|
22
|
+
};
|
|
23
|
+
}, []);
|
|
24
|
+
return boxWidth;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Hook to detect terminal size category and provide responsive utilities
|
|
28
|
+
* @returns Object with terminal width, size category, and utility functions
|
|
29
|
+
*/
|
|
30
|
+
export const useResponsiveTerminal = () => {
|
|
31
|
+
const boxWidth = useTerminalWidth();
|
|
32
|
+
const actualWidth = process.stdout.columns || 80;
|
|
33
|
+
// Define breakpoints for terminal sizes
|
|
34
|
+
const getSize = (width) => {
|
|
35
|
+
if (width < 60)
|
|
36
|
+
return 'narrow';
|
|
37
|
+
if (width < 100)
|
|
38
|
+
return 'normal';
|
|
39
|
+
return 'wide';
|
|
40
|
+
};
|
|
41
|
+
const size = getSize(actualWidth);
|
|
42
|
+
// Utility to truncate long text with ellipsis
|
|
43
|
+
const truncate = (text, maxLength) => {
|
|
44
|
+
if (text.length <= maxLength)
|
|
45
|
+
return text;
|
|
46
|
+
return text.slice(0, maxLength - 3) + '...';
|
|
47
|
+
};
|
|
48
|
+
// Utility to truncate path intelligently (keep end of path)
|
|
49
|
+
const truncatePath = (pathStr, maxLength) => {
|
|
50
|
+
if (pathStr.length <= maxLength)
|
|
51
|
+
return pathStr;
|
|
52
|
+
return '...' + pathStr.slice(-(maxLength - 3));
|
|
53
|
+
};
|
|
54
|
+
return {
|
|
55
|
+
boxWidth,
|
|
56
|
+
actualWidth,
|
|
57
|
+
size,
|
|
58
|
+
isNarrow: size === 'narrow',
|
|
59
|
+
isNormal: size === 'normal',
|
|
60
|
+
isWide: size === 'wide',
|
|
61
|
+
truncate,
|
|
62
|
+
truncatePath,
|
|
63
|
+
};
|
|
64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QACX,IAAI;QACJ,QAAQ,EAAE,IAAI,KAAK,QAAQ;QAC3B,QAAQ,EAAE,IAAI,KAAK,QAAQ;QAC3B,MAAM,EAAE,IAAI,KAAK,MAAM;QACvB,QAAQ;QACR,YAAY;KACZ,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Colors, ThemePreset } from '../types/ui.js';
|
|
2
|
+
interface ThemeContextType {
|
|
3
|
+
currentTheme: ThemePreset;
|
|
4
|
+
colors: Colors;
|
|
5
|
+
setCurrentTheme: (theme: ThemePreset) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const ThemeContext: import("react").Context<ThemeContextType | null>;
|
|
8
|
+
export declare function useTheme(): ThemeContextType;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=useTheme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../src/hooks/useTheme.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,MAAM,EAAE,WAAW,EAAC,MAAM,YAAY,CAAC;AAEpD,UAAU,gBAAgB;IACzB,YAAY,EAAE,WAAW,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;CAC9C;AAED,eAAO,MAAM,YAAY,kDAA+C,CAAC;AAEzE,wBAAgB,QAAQ,IAAI,gBAAgB,CAO3C"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useContext, createContext } from 'react';
|
|
2
|
+
export const ThemeContext = createContext(null);
|
|
3
|
+
export function useTheme() {
|
|
4
|
+
const context = useContext(ThemeContext);
|
|
5
|
+
if (!context) {
|
|
6
|
+
throw new Error('useTheme must be used within a ThemeProvider');
|
|
7
|
+
}
|
|
8
|
+
return context;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=useTheme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTheme.js","sourceRoot":"","sources":["../../src/hooks/useTheme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,aAAa,EAAC,MAAM,OAAO,CAAC;AAShD,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAA0B,IAAI,CAAC,CAAC;AAEzE,MAAM,UAAU,QAAQ;IACvB,MAAM,OAAO,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;IAEzC,IAAI,CAAC,OAAO,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,OAAO,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { ThemePreset } from '../types/ui.js';
|
|
2
|
+
export interface AIProviderConfig {
|
|
3
|
+
name: string;
|
|
4
|
+
type: string;
|
|
5
|
+
models: string[];
|
|
6
|
+
requestTimeout?: number;
|
|
7
|
+
socketTimeout?: number;
|
|
8
|
+
maxRetries?: number;
|
|
9
|
+
connectionPool?: {
|
|
10
|
+
idleTimeout?: number;
|
|
11
|
+
cumulativeMaxIdleTimeout?: number;
|
|
12
|
+
};
|
|
13
|
+
config: {
|
|
14
|
+
baseURL?: string;
|
|
15
|
+
apiKey?: string;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export interface ProviderConfig {
|
|
20
|
+
name: string;
|
|
21
|
+
baseUrl?: string;
|
|
22
|
+
apiKey?: string;
|
|
23
|
+
models: string[];
|
|
24
|
+
requestTimeout?: number;
|
|
25
|
+
socketTimeout?: number;
|
|
26
|
+
maxRetries?: number;
|
|
27
|
+
organizationId?: string;
|
|
28
|
+
timeout?: number;
|
|
29
|
+
connectionPool?: {
|
|
30
|
+
idleTimeout?: number;
|
|
31
|
+
cumulativeMaxIdleTimeout?: number;
|
|
32
|
+
};
|
|
33
|
+
[key: string]: unknown;
|
|
34
|
+
}
|
|
35
|
+
export interface AppConfig {
|
|
36
|
+
auth?: {
|
|
37
|
+
url: string;
|
|
38
|
+
apiKey: string;
|
|
39
|
+
};
|
|
40
|
+
assistantName?: string;
|
|
41
|
+
providers?: {
|
|
42
|
+
name: string;
|
|
43
|
+
baseUrl?: string;
|
|
44
|
+
apiKey?: string;
|
|
45
|
+
models: string[];
|
|
46
|
+
requestTimeout?: number;
|
|
47
|
+
socketTimeout?: number;
|
|
48
|
+
connectionPool?: {
|
|
49
|
+
idleTimeout?: number;
|
|
50
|
+
cumulativeMaxIdleTimeout?: number;
|
|
51
|
+
};
|
|
52
|
+
[key: string]: unknown;
|
|
53
|
+
}[];
|
|
54
|
+
}
|
|
55
|
+
export interface UserPreferences {
|
|
56
|
+
lastProvider?: string;
|
|
57
|
+
lastModel?: string;
|
|
58
|
+
providerModels?: {
|
|
59
|
+
[key in string]?: string;
|
|
60
|
+
};
|
|
61
|
+
lastUpdateCheck?: number;
|
|
62
|
+
selectedTheme?: ThemePreset;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,YAAY,CAAC;AAI5C,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE;QAChB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,wBAAwB,CAAC,EAAE,MAAM,CAAC;KAClC,CAAC;IACF,MAAM,EAAE;QACP,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,MA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B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE;SACf,GAAG,IAAI,MAAM,CAAC,CAAC,EAAE,MAAM;KACxB,CAAC;IACF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,WAAW,CAAC;CAC5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAC;AACrB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAC;AACrB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface Colors {
|
|
2
|
+
white: string;
|
|
3
|
+
black: string;
|
|
4
|
+
primary: string;
|
|
5
|
+
muted: string;
|
|
6
|
+
tool: string;
|
|
7
|
+
secondary: string;
|
|
8
|
+
success: string;
|
|
9
|
+
error: string;
|
|
10
|
+
info: string;
|
|
11
|
+
warning: string;
|
|
12
|
+
}
|
|
13
|
+
export interface Theme {
|
|
14
|
+
name: string;
|
|
15
|
+
displayName: string;
|
|
16
|
+
colors: Colors;
|
|
17
|
+
}
|
|
18
|
+
export type ThemePreset = 'main';
|
|
19
|
+
//# sourceMappingURL=ui.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/types/ui.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,KAAK;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC"}
|
package/dist/types/ui.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/types/ui.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type MessageType = 'info' | 'error' | 'success' | 'warning';
|
|
2
|
+
export interface NpmRegistryResponse {
|
|
3
|
+
version: string;
|
|
4
|
+
name: string;
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}
|
|
7
|
+
export interface UpdateInfo {
|
|
8
|
+
hasUpdate: boolean;
|
|
9
|
+
currentVersion: string;
|
|
10
|
+
latestVersion?: string;
|
|
11
|
+
updateCommand?: string;
|
|
12
|
+
updateMessage?: string;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/types/utils.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;AAEnE,MAAM,WAAW,mBAAmB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,UAAU;IAC1B,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;CACvB"}
|