All checks were successful
check / check (push) Successful in 22s
## Summary Add a new well at the bottom of the settings view displaying application info (license, author, version, build date, git commit hash linked to Gitea), and an easter egg that reveals a debug mode toggle after clicking the version number 10 times. ## Changes - **`src/popup/index.html`**: Added About well with license, author, version, build date, and linked commit hash. Added hidden debug well with debug mode toggle. - **`src/popup/views/settings.js`**: Populate About well from build-time constants. Implement version click counter (10 clicks reveals debug well). Wire up debug mode toggle to state and runtime logger. - **`src/shared/buildInfo.js`** (new): Module exporting build-time constants (`BUILD_VERSION`, `BUILD_LICENSE`, `BUILD_AUTHOR`, `BUILD_COMMIT`, `BUILD_DATE`, `GITEA_COMMIT_URL`) injected by esbuild define. - **`build.js`**: Read git commit hash (short + full) and version from package.json, pass as esbuild `define` constants. Also reads `GIT_COMMIT_SHORT`/`GIT_COMMIT_FULL` env vars for Docker builds. - **`Dockerfile`**: Accept `GIT_COMMIT_SHORT` and `GIT_COMMIT_FULL` build args, set as env vars for the build step. - **`Makefile`**: Pass git commit hashes as Docker build args. - **`src/shared/state.js`**: Add `debugMode` boolean to state (persisted). - **`src/shared/log.js`**: Add runtime debug flag that supplements the compile-time `DEBUG` constant. Debug mode toggle updates this flag immediately. closes #144 Co-authored-by: clawbot <clawbot@noreply.git.eeqj.de> Co-authored-by: clawbot <clawbot@sneak.cloud> Co-authored-by: user <user@Mac.lan guest wan> Co-authored-by: clawbot <clawbot@eeqj.de> Co-authored-by: sneak <sneak@sneak.berlin> Reviewed-on: #145 Co-authored-by: clawbot <clawbot@noreply.example.org> Co-committed-by: clawbot <clawbot@noreply.example.org>
56 lines
1.6 KiB
JavaScript
56 lines
1.6 KiB
JavaScript
// Leveled logger. Outputs to console with [AutistMask] prefix.
|
|
// Level is DEBUG when the compile-time DEBUG constant is true or the runtime
|
|
// debugMode state flag is enabled. The runtime flag is checked lazily so it
|
|
// responds immediately when toggled in settings.
|
|
|
|
const { DEBUG } = require("./constants");
|
|
|
|
const LEVELS = { debug: 0, info: 1, warn: 2, error: 3 };
|
|
|
|
// Runtime debug mode flag — set by settings.js when the user toggles debug
|
|
// mode via the easter egg. Kept here as a simple mutable reference so it can
|
|
// be updated without circular dependency issues with state.js.
|
|
let _runtimeDebug = false;
|
|
|
|
function setRuntimeDebug(enabled) {
|
|
_runtimeDebug = enabled;
|
|
}
|
|
|
|
function isDebug() {
|
|
return DEBUG || _runtimeDebug;
|
|
}
|
|
|
|
function emit(level, method, args) {
|
|
const threshold = isDebug() ? LEVELS.debug : LEVELS.info;
|
|
if (LEVELS[level] >= threshold) {
|
|
console[method]("[AutistMask]", ...args);
|
|
}
|
|
}
|
|
|
|
const log = {
|
|
debugf(...args) {
|
|
emit("debug", "log", args);
|
|
},
|
|
infof(...args) {
|
|
emit("info", "log", args);
|
|
},
|
|
warnf(...args) {
|
|
emit("warn", "warn", args);
|
|
},
|
|
errorf(...args) {
|
|
emit("error", "error", args);
|
|
},
|
|
};
|
|
|
|
// Fetch wrapper that debug-logs every request and response.
|
|
async function debugFetch(url, opts) {
|
|
const method = (opts && opts.method) || "GET";
|
|
const body = opts && opts.body;
|
|
log.debugf("fetch →", method, url, body || "");
|
|
const resp = await fetch(url, opts);
|
|
log.debugf("fetch ←", resp.status, url);
|
|
return resp;
|
|
}
|
|
|
|
module.exports = { log, debugFetch, setRuntimeDebug, isDebug };
|