diff options
| author | Adam Malczewski <[email protected]> | 2026-09-05 17:33:06 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-09-05 17:33:06 +0900 |
| commit | 254f90a4081a3f15dfe54277da922579dbaee254 (patch) | |
| tree | f5f4e409196109baf938cd9d557e244242df18ce /src/core/plugin-abi/version.ts | |
| parent | 535215bfd1fee6087613108f42d28cd2807184d3 (diff) | |
| download | dispatch-web-254f90a4081a3f15dfe54277da922579dbaee254.tar.gz dispatch-web-254f90a4081a3f15dfe54277da922579dbaee254.zip | |
feat(layout): plan 04 — ABI layout.applyOps + reset affordance
Diffstat (limited to 'src/core/plugin-abi/version.ts')
| -rw-r--r-- | src/core/plugin-abi/version.ts | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/src/core/plugin-abi/version.ts b/src/core/plugin-abi/version.ts index becae87..e5a0168 100644 --- a/src/core/plugin-abi/version.ts +++ b/src/core/plugin-abi/version.ts @@ -1,7 +1,9 @@ /** * The frontend plugin ABI version + the semver handshake (plan 03 §3.2). * - * FRONTEND_ABI_VERSION is bumped on BREAKING ABI changes only. A plugin's + * FRONTEND_ABI_VERSION is bumped on BREAKING ABI changes only — an ADDITIVE + * member bumps the MINOR (plan 04 added `layout`: "1" → "1.1"; v1 plugins + * keep working, see the bare-major rule below). A plugin's * `manifest.frontend.apiVersion` is a semver RANGE that must include the * host's version; a mismatch lists the plugin as "incompatible frontend * plugin" in the manager UI and its module is NEVER imported. @@ -12,17 +14,26 @@ * major-only versions/ranges ("1", "^1") — the ABI's version grammar is * single-number, normalized here to x.y.z with zeros — because a frontend * ABI ("1") is not a kernel release ("0.1.0") and authors declare `"^1"`. + * A BARE-major range ("1", "^1", "~1" — no explicit minor) is a + * MAJOR-compatibility claim: it accepts every additive (minor) bump of that + * major, which is what makes "^1"/"1" plugins keep working on the 1.1 ABI + * (an author pinning minor/patch declares it explicitly: "1.0.0", "~1.0"). */ -export const FRONTEND_ABI_VERSION = "1"; +export const FRONTEND_ABI_VERSION = "1.1"; -/** The host version the handshake checks against (normalized to semver). */ -const HOST_VERSION = "1.0.0"; +/** + * The host version the handshake checks against (normalized to semver) — + * tracks FRONTEND_ABI_VERSION's major.minor at a 0 patch. + */ +const HOST_VERSION = "1.1.0"; interface SemVer { readonly major: number; readonly minor: number; readonly patch: number; + /** The range string named the minor EXPLICITLY (a pin, not a bare major). */ + readonly explicitMinor: boolean; } /** Parse a 1–3 component version ("1", "1.0", "1.0.0") — missing parts are 0. */ @@ -33,6 +44,7 @@ function parseSemver(version: string): SemVer | null { major: Number(match[1]), minor: Number(match[2] ?? 0), patch: Number(match[3] ?? 0), + explicitMinor: match[2] !== undefined, }; } @@ -59,7 +71,7 @@ export function isFrontendCompatible(apiVersion: string, hostVersion = HOST_VERS if (min === null) return false; if (!gte(host, min)) return false; if (min.major === 0) { - return host.major === 0 && host.minor === min.minor; + return host.major === 0 && (min.explicitMinor ? host.minor === min.minor : true); } return host.major === min.major; } @@ -67,6 +79,9 @@ export function isFrontendCompatible(apiVersion: string, hostVersion = HOST_VERS const min = parseSemver(range.slice(1)); if (min === null) return false; if (!gte(host, min)) return false; + // A BARE "~1" is a major-compatibility claim (any 1.x.y); an explicit + // minor ("~1.0") pins the minor, as tilde always has. + if (!min.explicitMinor) return host.major === min.major; return host.major === min.major && host.minor === min.minor; } if (range.startsWith(">=")) { @@ -76,5 +91,9 @@ export function isFrontendCompatible(apiVersion: string, hostVersion = HOST_VERS } const exact = parseSemver(range); if (exact === null) return false; + // A BARE major ("1") names the major only — it accepts that major's + // additive bumps (the "v1 plugins keep working" rule). An explicit + // version ("1.0", "1.0.0") pins exactly, as before. + if (!exact.explicitMinor) return host.major === exact.major; return host.major === exact.major && host.minor === exact.minor && host.patch === exact.patch; } |
