Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 185x 185x 185x 185x 185x 185x 185x 54x 54x 157x 157x 1x | import type { PanelSettings, TriggerPosition, Severity, SnapshotSettings, SnapshotScheduleInterval } from "./types";
/**
* Severity color scheme type (CSS values, not Tailwind classes)
*/
export interface SeverityColorScheme {
bg: string;
bgDark: string;
border: string;
borderDark: string;
text: string;
textDark: string;
accent: string;
accentRgb: string;
}
/**
* Default storage key for settings persistence
*/
export const DEFAULT_STORAGE_KEY = "memory-monitor-panel-settings";
/**
* Default panel settings
*/
export const DEFAULT_SETTINGS: PanelSettings = {
warningThreshold: 70,
criticalThreshold: 90,
autoGCThreshold: null,
enableAutoGC: false,
interval: 1000,
theme: "system",
panelWidth: 400,
snapshot: {
maxSnapshots: 10,
scheduleInterval: "off",
autoDeleteOldest: true,
},
historySize: 50,
};
/**
* History size constraints
*/
export const HISTORY_SIZE_LIMITS = {
min: 10,
max: 200,
default: 50,
} as const;
/**
* Default trigger button position
*/
export const DEFAULT_TRIGGER_POSITION: TriggerPosition = {
bottom: 20,
right: 20,
};
/**
* Panel dimension constraints
*/
export const PANEL_DIMENSIONS = {
minWidth: 420,
maxWidth: 600,
defaultWidth: 420,
} as const;
/**
* Animation durations in milliseconds
*/
export const ANIMATION_DURATION = {
panelSlide: 300,
sectionCollapse: 200,
chartUpdate: 300,
alertFade: 150,
} as const;
/**
* Auto-GC cooldown period in milliseconds
*/
export const AUTO_GC_COOLDOWN_MS = 10000;
/**
* Default maximum number of snapshots to store
*/
export const DEFAULT_MAX_SNAPSHOTS = 10;
/**
* Maximum allowed snapshots limit
*/
export const MAX_SNAPSHOTS_LIMIT = 50;
/**
* Minimum allowed snapshots
*/
export const MIN_SNAPSHOTS_LIMIT = 1;
/**
* Snapshot schedule options with their interval in milliseconds
*/
export const SNAPSHOT_SCHEDULE_OPTIONS: readonly {
label: string;
value: SnapshotScheduleInterval;
intervalMs: number;
}[] = [
{ label: "Off", value: "off", intervalMs: 0 },
{ label: "Every 1 sec", value: "1sec", intervalMs: 1000 },
{ label: "Every 10 sec", value: "10sec", intervalMs: 10 * 1000 },
{ label: "Every 1 min", value: "1min", intervalMs: 60 * 1000 },
{ label: "Every 5 min", value: "5min", intervalMs: 5 * 60 * 1000 },
{ label: "Every 10 min", value: "10min", intervalMs: 10 * 60 * 1000 },
{ label: "Every 30 min", value: "30min", intervalMs: 30 * 60 * 1000 },
{ label: "Every 1 hour", value: "1hour", intervalMs: 60 * 60 * 1000 },
{ label: "Every 6 hours", value: "6hour", intervalMs: 6 * 60 * 60 * 1000 },
{ label: "Every 24 hours", value: "24hour", intervalMs: 24 * 60 * 60 * 1000 },
] as const;
/**
* Default snapshot settings
*/
export const DEFAULT_SNAPSHOT_SETTINGS: SnapshotSettings = {
maxSnapshots: DEFAULT_MAX_SNAPSHOTS,
scheduleInterval: "off",
autoDeleteOldest: true,
};
/**
* @deprecated Use DEFAULT_MAX_SNAPSHOTS instead
* Maximum number of snapshots to store (legacy)
*/
export const MAX_SNAPSHOTS = DEFAULT_MAX_SNAPSHOTS;
/**
* Polling interval options in milliseconds
*/
export const INTERVAL_OPTIONS = [
{ label: "500ms", value: 500 },
{ label: "1s", value: 1000 },
{ label: "2s", value: 2000 },
{ label: "5s", value: 5000 },
{ label: "10s", value: 10000 },
] as const;
/**
* Color scheme for severity levels (CSS hex values)
*/
export const SEVERITY_COLORS: Record<Severity, SeverityColorScheme> = {
normal: {
bg: "#f0fdf4", // green-50
bgDark: "#052e16", // green-950
border: "#bbf7d0", // green-200
borderDark: "#166534", // green-800
text: "#15803d", // green-700
textDark: "#86efac", // green-300
accent: "#22c55e", // green-500
accentRgb: "34, 197, 94",
},
warning: {
bg: "#fffbeb", // amber-50
bgDark: "#451a03", // amber-950
border: "#fde68a", // amber-200
borderDark: "#92400e", // amber-800
text: "#b45309", // amber-700
textDark: "#fcd34d", // amber-300
accent: "#f59e0b", // amber-500
accentRgb: "245, 158, 11",
},
critical: {
bg: "#fef2f2", // red-50
bgDark: "#450a0a", // red-950
border: "#fecaca", // red-200
borderDark: "#991b1b", // red-800
text: "#b91c1c", // red-700
textDark: "#fca5a5", // red-300
accent: "#ef4444", // red-500
accentRgb: "239, 68, 68",
},
};
/**
* Chart color palette
*/
export const CHART_COLORS = {
primary: "#6366f1", // indigo-500
primaryLight: "#818cf8", // indigo-400
secondary: "#a855f7", // purple-500
secondaryLight: "#c084fc", // purple-400
success: "#22c55e", // green-500
warning: "#f59e0b", // amber-500
danger: "#ef4444", // red-500
gray: "#9ca3af", // gray-400
grayLight: "#e5e7eb", // gray-200
grayDark: "#4b5563", // gray-600
} as const;
/**
* Trend colors
*/
export const TREND_COLORS = {
increasing: CHART_COLORS.danger,
decreasing: CHART_COLORS.success,
stable: CHART_COLORS.gray,
} as const;
/**
* Default keyboard shortcut
*/
export const DEFAULT_SHORTCUT = "ctrl+shift+m";
/**
* Z-index defaults
*/
export const Z_INDEX = {
trigger: 9998,
panel: 9999,
overlay: 9997,
} as const;
/**
* Tab configuration
*/
export const PANEL_TABS = [
{ id: "overview", label: "Overview", icon: "chart" },
{ id: "history", label: "History", icon: "clock" },
{ id: "snapshots", label: "Snapshots", icon: "camera" },
{ id: "settings", label: "Settings", icon: "cog" },
] as const;
/**
* Leak sensitivity thresholds
*/
export const LEAK_SENSITIVITY_THRESHOLDS = {
low: { minSamples: 10, threshold: 0.8 },
medium: { minSamples: 5, threshold: 0.6 },
high: { minSamples: 3, threshold: 0.4 },
} as const;
/**
* Format bytes to human-readable string
*/
export function formatBytes(bytes: number | null | undefined): string {
Iif (bytes == null) return "N/A";
Iif (bytes === 0) return "0 B";
const units = ["B", "KB", "MB", "GB"];
const k = 1024;
const i = Math.floor(Math.log(bytes) / Math.log(k));
const value = bytes / Math.pow(k, i);
return `${value.toFixed(i > 1 ? 1 : 0)} ${units[i]}`;
}
/**
* Format number with thousand separators
*/
export function formatNumber(num: number | null | undefined): string {
Iif (num == null) return "N/A";
return num.toLocaleString();
}
/**
* Format percentage
*/
export function formatPercentage(value: number | null | undefined): string {
Iif (value == null) return "N/A";
return `${value.toFixed(1)}%`;
}
/**
* Format timestamp to locale time string
*/
export function formatTime(timestamp: number): string {
return new Date(timestamp).toLocaleTimeString("en-US", {
hour12: false,
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
});
}
|