Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

feat: remove useless imports

Asuka1098a0297f48e20
diff --git a/packages/harper.js/api-extractor.json b/packages/harper.js/api-extractor.json
index 5663c502e..e27c69bb4 100644
--- a/packages/harper.js/api-extractor.json
+++ b/packages/harper.js/api-extractor.json
@@ -14,6 +14,9 @@
"extractorMessageReporting": {
"ae-missing-release-tag": {
"logLevel": "none"
+ },
+ "ae-forgotten-export": {
+ "logLevel": "none"
}
}
}
diff --git a/packages/harper.js/src/Linter.ts b/packages/harper.js/src/Linter.ts
index ab72124ff..b2100d168 100644
--- a/packages/harper.js/src/Linter.ts
+++ b/packages/harper.js/src/Linter.ts
@@ -1,4 +1,4 @@
-import type { Lint, Span, Suggestion, InitInput as BinaryInitInput } from 'harper-wasm';
+import type { Lint, Span, Suggestion } from 'harper-wasm';
import { LintConfig, LintOptions } from './main';
/** An interface for an object that can perform linting actions. */
@@ -67,5 +67,5 @@ export default interface Linter {
export interface LinterInit {
/** The module or path to the WebAssembly binary. */
- binary: BinaryInitInput | Promise<BinaryInitInput>;
+ binary: string;
}
diff --git a/packages/harper.js/src/LocalLinter.ts b/packages/harper.js/src/LocalLinter.ts
index f87e733d8..93b52b47a 100644
--- a/packages/harper.js/src/LocalLinter.ts
+++ b/packages/harper.js/src/LocalLinter.ts
@@ -2,11 +2,11 @@ import type { Lint, Span, Suggestion, Linter as WasmLinter } from 'harper-wasm';
import { Language } from 'harper-wasm';
import Linter, { LinterInit } from './Linter';
import { LintConfig, LintOptions } from './main';
-import { binary, BinaryInit, loadBinary } from './binary';
+import { binary, loadBinary } from './binary';
/** A Linter that runs in the current JavaScript context (meaning it is allowed to block the event loop). */
export default class LocalLinter implements Linter {
- private binary: BinaryInit;
+ private binary: string;
private inner: WasmLinter | undefined;
constructor(init: LinterInit) {
diff --git a/packages/harper.js/src/WorkerLinter/index.ts b/packages/harper.js/src/WorkerLinter/index.ts
index 86b404808..229e7dcf1 100644
--- a/packages/harper.js/src/WorkerLinter/index.ts
+++ b/packages/harper.js/src/WorkerLinter/index.ts
@@ -11,10 +11,6 @@ type RequestItem = {
request: DeserializedRequest;
};
-export interface WorkerLinterInit extends LinterInit {
- binary: string;
-}
-
/** A Linter that spins up a dedicated web worker to do processing on a separate thread.
* Main benefit: this Linter will not block the event loop for large documents.
*
@@ -25,9 +21,8 @@ export default class WorkerLinter implements Linter {
private requestQueue: RequestItem[];
private working = true;
- constructor(init: WorkerLinterInit) {
+ constructor(init: LinterInit) {
this.binary = init.binary;
-
this.worker = new Worker();
this.requestQueue = [];
diff --git a/packages/harper.js/src/binary.ts b/packages/harper.js/src/binary.ts
index 2160d3633..4dad4d7c0 100644
--- a/packages/harper.js/src/binary.ts
+++ b/packages/harper.js/src/binary.ts
@@ -1,13 +1,11 @@
-import type { InitInput as BinaryInitInput } from 'harper-wasm';
-import * as wasm from 'harper-wasm';
+import { default as _binary } from 'harper-wasm/harper_wasm_bg.wasm?url';
+import { default as _inlinedBinary } from 'harper-wasm/harper_wasm_bg.wasm?inline';
-export type BinaryInit = BinaryInitInput | Promise<BinaryInitInput>;
-
-export async function loadBinary(binary: BinaryInit): Promise<typeof wasm> {
+export async function loadBinary(binary: string) {
const exports = await import('harper-wasm');
await exports.default({ module_or_path: binary });
return exports;
}
-export { default as binary } from 'harper-wasm/harper_wasm_bg.wasm?url';
-export { default as inlinedBinary } from 'harper-wasm/harper_wasm_bg.wasm?inline';
+export const binary: string = _binary;
+export const inlinedBinary: string = _inlinedBinary;
diff --git a/packages/harper.js/src/main.ts b/packages/harper.js/src/main.ts
index 353be053d..4cf97be58 100644
--- a/packages/harper.js/src/main.ts
+++ b/packages/harper.js/src/main.ts
@@ -1,8 +1,8 @@
export { Lint, Span, Suggestion, SuggestionKind } from 'harper-wasm';
+export type { default as Linter, LinterInit } from './Linter';
export { default as LocalLinter } from './LocalLinter';
export { default as WorkerLinter } from './WorkerLinter';
-export type { default as Linter } from './Linter';
-export { type BinaryInit, binary, inlinedBinary, loadBinary } from './binary';
+export { binary, inlinedBinary } from './binary';
/** A linting rule configuration dependent on upstream Harper's available rules.
* This is a record, since you shouldn't hard-code the existence of any particular rules and should generalize based on this struct. */