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 | 184x 50x 50x 64x 2x 12x 50x 64x 4x 60x 60x | import type { PanelMode } from "../types";
/**
* Check if running on server (SSR)
*/
export function isSSR(): boolean {
return typeof window === "undefined";
}
/**
* Check if running in development mode
*/
export function isDevelopment(): boolean {
// Check for common development environment indicators
Eif (typeof process !== "undefined" && process.env) {
return process.env.NODE_ENV === "development";
}
// Fallback: check if running on localhost
if (!isSSR()) {
const hostname = window.location?.hostname;
return (
hostname === "localhost" ||
hostname === "127.0.0.1" ||
hostname === "0.0.0.0" ||
hostname?.startsWith("192.168.") ||
hostname?.endsWith(".local")
);
}
return false;
}
/**
* Check if running in production mode
*/
export function isProduction(): boolean {
if (typeof process !== "undefined" && process.env) {
return process.env.NODE_ENV === "production";
}
return !isDevelopment();
}
/**
* Determine if the panel should render based on mode
*
* @param mode - Panel visibility mode
* @returns Whether the panel should render
*/
export function getShouldRender(mode: PanelMode): boolean {
switch (mode) {
case "always":
return true;
case "never":
case "headless":
// "never" and "headless" both don't render UI
// The difference is handled in getShouldActivate
return false;
case "production":
return isProduction();
case "development":
default:
return isDevelopment();
}
}
/**
* Determine if monitoring features should be active
*
* Features can be active even when panel is not rendered (headless mode).
* - "headless": No UI but monitoring runs (for production callbacks)
* - "never": No UI and no monitoring (completely disabled)
*
* @param mode - Panel visibility mode
* @param disableInProduction - Whether to disable in production
* @returns Whether features should be active
*/
export function getShouldActivate(
mode: PanelMode,
disableInProduction: boolean
): boolean {
// Only "never" completely disables monitoring
// "headless" keeps monitoring active without UI
if (mode === "never") {
return false;
}
// If disableInProduction is true and we're in production, don't activate
Iif (disableInProduction && isProduction()) {
return false;
}
return true;
}
|