UNPKG

@storm-software/config-tools

Version:

A package containing various utilities to support custom workspace configurations and environment management for Storm Software projects, including configuration file handling, environment variable management, and logging utilities.

84 lines (77 loc) 3.3 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/utilities/colors.ts var DEFAULT_COLOR_CONFIG = { light: { background: "#fafafa", foreground: "#1d1e22", brand: "#1fb2a6", alternate: "#db2777", help: "#5C4EE5", success: "#087f5b", info: "#0550ae", debug: "#8afafc", warning: "#e3b341", danger: "#D8314A", fatal: "#51070f", performance: "#13c302", link: "#3fa6ff", positive: "#22c55e", negative: "#dc2626", gradient: ["#1fb2a6", "#db2777", "#5C4EE5"] }, dark: { background: "#1d1e22", foreground: "#cbd5e1", brand: "#2dd4bf", alternate: "#db2777", help: "#818cf8", success: "#10b981", info: "#58a6ff", debug: "#8afafc", warning: "#f3d371", danger: "#D8314A", fatal: "#a40e26", performance: "#80fd74", link: "#3fa6ff", positive: "#22c55e", negative: "#dc2626", gradient: ["#1fb2a6", "#db2777", "#818cf8"] } }; function getColors(config) { if (!_optionalChain([config, 'optionalAccess', _ => _.colors]) || typeof config.colors !== "object" || !config.colors["dark"] && (!config.colors["base"] || typeof config.colors !== "object" || !_optionalChain([config, 'access', _2 => _2.colors, 'access', _3 => _3["base"], 'optionalAccess', _4 => _4["dark"]]))) { return DEFAULT_COLOR_CONFIG; } if (config.colors["base"]) { if (typeof config.colors["base"]["dark"] === "object") { return config.colors["base"]["dark"]; } else if (config.colors["base"]["dark"] === "string") { return config.colors["base"]; } } if (typeof config.colors["dark"] === "object") { return config.colors["dark"]; } return _nullishCoalesce(config.colors, () => ( DEFAULT_COLOR_CONFIG)); } function getColor(key, config) { const colors = getColors(config); const result = (typeof colors["dark"] === "object" ? colors["dark"][key] : colors[key]) || DEFAULT_COLOR_CONFIG["dark"][key] || DEFAULT_COLOR_CONFIG[key]; if (result) { return result; } if (key === "link" || key === "debug") { return getColor("info", config); } else if (key === "fatal") { return getColor("danger", config); } return getColor("brand", config); } function getGradient(config) { const colors = getColors(config); const result = (typeof colors["dark"] === "object" ? colors["dark"].gradient : colors.gradient) || DEFAULT_COLOR_CONFIG["dark"].gradient; if (result && Array.isArray(result) && result.length > 0) { return result; } return void 0; } exports.DEFAULT_COLOR_CONFIG = DEFAULT_COLOR_CONFIG; exports.getColors = getColors; exports.getColor = getColor; exports.getGradient = getGradient;