Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
fix(harper.js): remove breaking change by making arg optional
Elijah Potter0f2c4c01caa9
diff --git a/packages/harper.js/src/BinaryModule.ts b/packages/harper.js/src/BinaryModule.tsindex ef62df07d..8a7b96c92 100644--- a/packages/harper.js/src/BinaryModule.ts+++ b/packages/harper.js/src/BinaryModule.ts@@ -14,6 +14,17 @@ function inferGlueFlavor(binary: string): WasmGlueFlavor {return binary.includes('harper_wasm_slim') ? 'slim' : 'full';}+/**+ * Resolve the glue flavor for a binary module.+ *+ * `glueFlavor` is intentionally optional on the public `BinaryModule` interface so+ * older/custom BinaryModule-like objects remain structurally compatible. When it is+ * absent, fall back to inferring the flavor from the binary URL.+ */+export function resolveWasmGlueFlavor(binary: Pick<BinaryModule, 'url' | 'glueFlavor'>): WasmGlueFlavor {+ return binary.glueFlavor ?? inferGlueFlavor(typeof binary.url === 'string' ? binary.url : binary.url.href);+}+function loadGlue(glueFlavor: WasmGlueFlavor): WasmModule {if (glueFlavor === 'slim') {return defaultGlue as WasmModule;@@ -77,7 +88,7 @@ function loadBinary(binary: string, glueFlavor: WasmGlueFlavor) {export interface BinaryModule {url: string | URL;- glueFlavor: WasmGlueFlavor;+ glueFlavor?: WasmGlueFlavor;getDefaultLintConfigAsJSON(): Promise<string>;diff --git a/packages/harper.js/src/WorkerLinter/index.ts b/packages/harper.js/src/WorkerLinter/index.tsindex 6a483371e..56f989a1e 100644--- a/packages/harper.js/src/WorkerLinter/index.ts+++ b/packages/harper.js/src/WorkerLinter/index.ts@@ -1,5 +1,5 @@import type { Dialect, Lint, Suggestion } from 'harper-wasm';-import type { BinaryModule } from '../BinaryModule';+import { resolveWasmGlueFlavor, type BinaryModule } from '../BinaryModule';import type Linter from '../Linter';import type { LinterInit, WeirpackTestFailures } from '../Linter';import type { LintConfig, LintOptions, StructuredLintConfig } from '../main';@@ -38,7 +38,11 @@ export default class WorkerLinter implements Linter {this.worker.onmessage = () => {this.setupMainEventListeners();- this.worker.postMessage([this.binary.url, this.dialect, this.binary.glueFlavor]);+ this.worker.postMessage([+ this.binary.url,+ this.dialect,+ resolveWasmGlueFlavor(this.binary),+ ]);this.working = false;this.submitRemainingRequests();