Skip to content

Lower minAppVersion to 1.11.0 with runtime compatibility guards - #46

Merged
ClaudiaFang merged 3 commits into
mainfrom
claude/obsidian-version-adoption-56aej4
Jul 7, 2026
Merged

ClaudiaFang merged 3 commits into
mainfrom
claude/obsidian-version-adoption-56aej4

Conversation

@ClaudiaFang

Copy link
Copy Markdown
Member

Summary

Extends plugin compatibility to Obsidian 1.11.0 (from 1.13.0) by adding runtime guards for APIs that were introduced in later versions. This allows the plugin to run on older Obsidian installations while maintaining type safety through a new compatibility type-checking script.

Key Changes

  • Lowered minAppVersion from 1.13.0 to 1.11.0 in manifest.json and versions.json
  • Added runtime API guards for newer Obsidian features:
    • ButtonComponent.setDestructive() (added in 1.13) — wrapped in applyDestructiveStyle() helper that safely calls the method only if present
    • PluginSettingTab.update() (added in 1.13) — checked at runtime before calling; falls back to manual re-render on older versions
    • SettingDefinitionItem type — declared locally since it doesn't exist in 1.11 typings; getSettingDefinitions() is only called by versions that understand it
  • Added compatibility type-checking script (scripts/typecheck-compat.mjs):
    • Dynamically resolves the target Obsidian API version from versions.json (or manifest.minAppVersion as fallback)
    • Installs matching Obsidian typings on-demand into a git-ignored cache
    • Generates a temporary tsconfig that points imports to the target version's types
    • Ensures all code compiles against the declared minAppVersion, catching any unguarded newer APIs at build time
  • Integrated into build pipeline — npm run build now runs typecheck:compat before esbuild
  • Added test coverage for the applyDestructiveStyle() compatibility helper, verifying it works on both old and new Obsidian versions

Implementation Details

The compatibility type-checking approach is dynamic and version-agnostic: bumping minAppVersion automatically re-points the check to the new target typings without code changes. The script caches typings per version to avoid repeated downloads. All runtime guards use defensive checks (typeof x === 'function') to gracefully degrade on older versions rather than throwing errors.

https://claude.ai/code/session_01SSikT9ZAfQF8K4SE3DatD3

claude added 3 commits July 7, 2026 01:53
Release 1.2.0 raised minAppVersion to 1.13.0, pushing users still on
Obsidian 1.11/1.12 back to the older 1.1.2 build via versions.json. Only
three 1.13-era APIs were in use; two were already runtime-guarded, but
ButtonComponent.setDestructive() would throw on older Obsidian.

- Guard setDestructive() behind applyDestructiveStyle() (no-ops on < 1.13).
- Declare SettingDefinitionItem locally and read update() via a cast so the
  forward-compatible settings code type-checks against 1.11 typings.
- Ship 1.2.1 with minAppVersion 1.11.0 (manifest.json + versions.json).
- Add tsconfig.compat.json and `npm run typecheck:compat` to type-check src
  against the 1.11 API, plus regression tests for applyDestructiveStyle.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SSikT9ZAfQF8K4SE3DatD3
The 1.11 compatibility gate previously hardcoded the target Obsidian
version in two places (an obsidian-1_11 alias devDependency and a static
tsconfig.compat.json), so bumping minAppVersion would silently leave the
check pinned to the old version.

Replace both with scripts/typecheck-compat.mjs, which reads the target from
versions.json (the entry for the current manifest version, falling back to
manifest.minAppVersion), installs the matching Obsidian typings into a
git-ignored cache on demand, and type-checks src against them. The gate now
follows minAppVersion automatically with no code changes.

Also fold `typecheck:compat` into `npm run build` so it runs wherever the
build runs (the husky pre-commit hook and any CI step that builds).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SSikT9ZAfQF8K4SE3DatD3
The repository has CodeQL "default setup" enabled, which rejects SARIF
uploads from an advanced workflow ("CodeQL analyses from advanced
configurations cannot be processed when the default setup is enabled"),
failing the Analyze check on every PR to main. Drop the advanced
.github/workflows/codeql.yml and let GitHub's default setup handle
CodeQL scanning.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SSikT9ZAfQF8K4SE3DatD3
@sonarqubecloud

sonarqubecloud Bot commented Jul 7, 2026

Copy link
Copy Markdown

@ClaudiaFang
ClaudiaFang merged commit 0fd289f into main Jul 7, 2026
18 of 19 checks passed
@ClaudiaFang
ClaudiaFang deleted the claude/obsidian-version-adoption-56aej4 branch July 7, 2026 02:44
@ClaudiaFang

Copy link
Copy Markdown
Member Author

🎉 This PR is included in version 1.2.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants