refactor: state.js → mutable object to fix 'assignment to constant' errors
CI / lint (push) Successful in 13s
CI / security (push) Successful in 8s
CI / test (push) Successful in 16s
CI / build (push) Successful in 6s

ES module imports are read-only live bindings — can't reassign
imported let/const variables. Replace individual 'export let' with
single 'export const state = {...}' mutable object.

All modules updated: import { state } from './state.js'
All state access changed to state.xxx pattern.

Fixes cascade of 'Assignment to constant variable' errors.
This commit is contained in:
2026-05-28 16:34:39 -04:00
parent 16e0860a69
commit 7866f93778
12 changed files with 10077 additions and 10308 deletions
+53 -49
View File
@@ -1,55 +1,59 @@
/* ObsiGate — Shared application state */
export const APP_VERSION = "1.5.0";
/* ObsiGate — Shared mutable application state.
Use state.xxx to read/write any value. ES module imports are read-only,
so we export a single mutable object instead of individual let bindings. */
export const state = {
APP_VERSION: "1.5.0",
// Core navigation state
export let currentVault = null;
export let currentPath = null;
export let allVaults = [];
export let selectedContextVault = "all";
// Core navigation
currentVault: null,
currentPath: null,
allVaults: [],
selectedContextVault: "all",
// Search state
export let searchTimeout = null;
export let searchAbortController = null;
export let advancedSearchOffset = 0;
export let advancedSearchTotal = 0;
export let advancedSearchSort = "relevance";
export let advancedSearchLastQuery = "";
export let suggestAbortController = null;
export let dropdownActiveIndex = -1;
export let dropdownItems = [];
export let currentSearchId = 0;
export let selectedTags = [];
export let searchCaseSensitive = false;
export let searchWholeWord = false;
export let searchRegex = false;
export let searchFilterVisible = false;
// Search
searchTimeout: null,
searchAbortController: null,
advancedSearchOffset: 0,
advancedSearchTotal: 0,
advancedSearchSort: "relevance",
advancedSearchLastQuery: "",
suggestAbortController: null,
dropdownActiveIndex: -1,
dropdownItems: [],
currentSearchId: 0,
selectedTags: [],
searchCaseSensitive: false,
searchWholeWord: false,
searchRegex: false,
searchFilterVisible: false,
// Search constants
export const SEARCH_HISTORY_KEY = "obsigate_search_history";
export const MAX_HISTORY_ENTRIES = 50;
export const SUGGEST_DEBOUNCE_MS = 150;
export const ADVANCED_SEARCH_LIMIT = 50;
export const MIN_SEARCH_LENGTH = 2;
export const SEARCH_TIMEOUT_MS = 30000;
// Search constants
SEARCH_HISTORY_KEY: "obsigate_search_history",
MAX_HISTORY_ENTRIES: 50,
SUGGEST_DEBOUNCE_MS: 150,
ADVANCED_SEARCH_LIMIT: 50,
MIN_SEARCH_LENGTH: 2,
SEARCH_TIMEOUT_MS: 30000,
// Viewer state
export let showingSource = false;
export let cachedRawSource = null;
export let editorView = null;
export let editorVault = null;
export let editorPath = null;
export let fallbackEditorEl = null;
export let _iconDebounceTimer = null;
// Viewer state
showingSource: false,
cachedRawSource: null,
editorView: null,
editorVault: null,
editorPath: null,
fallbackEditorEl: null,
_iconDebounceTimer: null,
// Outline/TOC state
export let outlineObserver = null;
export let activeHeadingId = null;
export let headingsCache = [];
export let rightSidebarVisible = true;
export let rightSidebarWidth = 280;
// Outline/TOC
outlineObserver: null,
activeHeadingId: null,
headingsCache: [],
rightSidebarVisible: true,
rightSidebarWidth: 280,
// Sidebar state
export let sidebarFilterCaseSensitive = false;
export let activeSidebarTab = "vaults";
export let filterDebounce = null;
export let vaultSettings = {};
// Sidebar
sidebarFilterCaseSensitive: false,
activeSidebarTab: "vaults",
filterDebounce: null,
vaultSettings: {},
};