Cross-Module Patterns
getbased uses typed Svelte presentation and TypeScript domain services. The static SvelteKit production build and native compatibility entry share those owners. Keep runtime imports ending in.js and use explicit dependencies and configured callbacks to avoid cycles. The architecture checker rejects new dependency cycles.
Compatibility handlers and delegated actions
Some retained native handlers call functions exposed onwindow, and modules may retain Object.assign(window, {...}) as a compatibility surface. Shared shell controls also use delegated actions installed by shell-actions.ts; lazy features expose loader or runtime entry points. New presentation belongs in Svelte components with typed props and feature-owned actions. Preserve existing action attributes and avoid installing a second handler over an already owned control.
When changing a handler, preserve its public name and availability at the time the control becomes usable. Do not install competing owners for the same compatibility export. Prefer feature-owned delegates and narrow typed callbacks for new wiring; do not expand global exports simply to avoid designing a dependency boundary.
Cross-module calls and runtime seams
Use a normal ES-module import for an allowed dependency:window calls remain compatibility paths, but the target direction is composition → UI/workflow → domain service → foundation/storage. See the architecture contract.
Decoupled refresh triggering
data.ts exposes registerRefreshCallback() so data code can request a refresh without importing the view/router graph. startup-orchestrator.ts calls registerAppRefreshCallback() from app-event-listeners.ts; that callback rebuilds the sidebar, navigates to state.currentView through its configured dependency, and updates the chat nudge.
This is one specific refresh seam. Other features have their own configured runtime callbacks; do not route every UI operation through a global service locator.
Svelte text and reviewed rich-content boundaries
Use ordinary Svelte interpolation for text. It escapes strings for HTML; do not pre-escape a label and then display the resulting entities literally.escapeHTML() where an existing HTML serializer requires it, and retain the URL policy in markdown.ts. Neither a component migration nor a sink-count update authorizes a new untrusted HTML sink.
See Svelte and Tailwind and the app’s presentation contract.
State access — import state from state.ts
state.ts exports a single shared mutable object. Any module that needs to read or write application state imports it directly:
state is never copied — always pass references or re-read from it. The object is also available as window._labState for debugging in the browser console.
The data parameter pattern — avoid redundant pipeline calls
getActiveData() is not cheap — it deep-clones the full marker schema and processes all entries. Rendering functions that might be called from multiple contexts accept an optional data parameter:
data once and pass it through to all sub-renderers:
Debug mode
isDebugMode() in utils.ts reads the labcharts-debug localStorage flag. All console.warn and console.error calls in production are gated behind this: