Expand description
User init.ts support.
At startup Fresh reads ~/.config/fresh/init.ts (if present) and feeds it
through the existing plugin pipeline as a plugin named init.ts. This is
the same code path as “Load Plugin from Buffer”, so reload, unload, and
per-plugin registration tagging are free.
Recovery: a lightweight crash fuse at
~/.config/fresh/logs/init.crashes counts consecutive init.ts failures
within a rolling window. After N failures the next launch auto-skips
init.ts until the user fixes or removes it. A successful evaluation
clears the counter.
Structs§
- Check
Diagnostic - Check
Report - Result of
fresh --cmd init check.
Enums§
- Check
Severity - Init
Outcome - Outcome of [
autoload]. - Load
Decision - Pre-flight for the caller: check fuse, return either the source to load or an outcome explaining why we’re not loading.
Constants§
- INIT_
PLUGIN_ NAME - Plugin name Fresh uses when loading init.ts — stable so hot-reload works.
- STARTER_
TEMPLATE - Starter content written by
init: Edit init.tswhen the file doesn’t exist yet. Every example is commented out — an empty init() body is valid and users un-comment what they want.
Functions§
- check
- decide_
load - describe
- Human-readable summary for the status bar / logs.
- ensure_
starter - Ensure
~/.config/fresh/init.tsexists. If absent, writes the starter template. Also refreshestypes/fresh.d.ts+tsconfig.jsonso the template’s/// <reference path=...directive resolves andgetEditor()type-checks in any TS-aware editor. Returns the (possibly newly-created)init.tspath. - init_
ts_ path - Resolve
~/.config/fresh/init.ts. - read_
init_ script - Read init.ts from disk. Returns
Ok(None)when the file simply doesn’t exist. - record_
success - Called after init.ts finishes cleanly. Resets the crash-fuse counter so the next launch starts from zero.
- refresh_
types_ scaffolding - Refresh
~/.config/fresh/types/fresh.d.tsfrom the embedded copy and writetsconfig.jsonif it isn’t already present. - should_
skip - Decide, without touching disk for the source, whether init.ts loading should run at all.
- write_
plugin_ declarations - Write
<config_dir>/types/plugins.d.tsfrom the.d.tsemit of each loaded plugin. The editor calls this after scanning every plugin directory, so by the timeinit.tsis evaluated the ambientFreshPluginRegistryis fully populated andeditor.getPluginApi("dashboard")resolves to the typed overload.