Both src/main.ts and src/linkManager.ts called getAPI() as class
field initializers. Class field initializers run at construction
time, before any lifecycle method. If Dataview loads after this
plugin (which is common), getAPI() returns null, onload() checks
this.api, finds null, prints "Dataview plugin is not available",
and returns. Plugin is dead. Load order doesn't matter because
the bug is in construction, not in load sequence.
Fix:
- src/main.ts line 70: api field initialized to null instead of
calling getAPI() at construction
- src/main.ts onload(): tries getAPI() first. If null, registers
for the dataview:api-ready event and initializes when Dataview
is ready. Event handlers moved to initEventHandlers() so they
can be called from either path.
- src/linkManager.ts line 11: api field initialized to null. Gets
set from main.ts after Dataview is ready.