All files / src/lib/tinymce/utils graph2dDebug.js

88.88% Statements 16/18
87.5% Branches 14/16
100% Functions 4/4
100% Lines 14/14

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                        4x 4x 4x 1x               12x 12x 12x 10x 1x     2x   7x         2x 1x         1x    
/**
 * Client-side Graph2D / TinyMCE graph debugging (complements graph2d-react built-in checks).
 *
 * Enable either:
 *   window.__GRAPH2D_DEBUG__ = true
 *   localStorage.setItem("graph2dDebug", "1")
 *
 * graph2d-react reads the same flags for its internal graph2dLog(); this module syncs
 * window.__GRAPH2D_DEBUG__ from localStorage on load and exposes helpers for app/plugin code.
 */
 
export function syncGraph2dDebugFromStorage() {
    Iif (typeof window === "undefined") return;
    try {
        if (typeof localStorage !== "undefined" && localStorage.getItem("graph2dDebug") === "1") {
            window.__GRAPH2D_DEBUG__ = true;
        }
    } catch {
        // ignore (private mode, etc.)
    }
}
 
export function isGraph2dClientDebug() {
    Iif (typeof window === "undefined") return false;
    try {
        if (window.__GRAPH2D_DEBUG__ === true) return true;
        if (typeof localStorage !== "undefined" && localStorage.getItem("graph2dDebug") === "1") {
            return true;
        }
    } catch {
        return false;
    }
    return false;
}
 
/** Verbose / opt-in only — same semantics as graph2d-react graph2dLog. */
export function graph2dClientLog(...args) {
    if (!isGraph2dClientDebug()) return;
    console.log("[Graph2D:app]", ...args);
}
 
/** Always visible — use for real integration failures (matches package graph2dWarn). */
export function graph2dClientWarn(...args) {
    console.warn("[Graph2D:app]", ...args);
}