Skip to content

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

Merge branch 'master' into feat/harper-binary-formats

Asuka1090228688a6a19
diff --cc packages/harper.js/package.json
index 87ed60fd6,61fd3b5fc..38e9d23e9
--- a/packages/harper.js/package.json
+++ b/packages/harper.js/package.json
@@@ -17,17 -17,14 +17,17 @@@
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
- "test": "vitest run --browser chromium"
+ "test": "vitest run",
+ "test:debug": "vitest run --browser.headless false --testTimeout 0",
+ "api:extractor": "api-extractor run",
+ "api:documenter": "api-documenter markdown -i temp"
},
"devDependencies": {
- "@microsoft/api-documenter": "^7.26.7",
- "@microsoft/api-extractor": "^7.49.2",
- "@vitest/browser": "^3.0.5",
+ "@microsoft/api-documenter": "^7.26.10",
+ "@microsoft/api-extractor": "^7.50.1",
+ "@vitest/browser": "^3.0.6",
"playwright": "^1.49.1",
- "typescript": "~5.7.3",
+ "typescript": "^5.7.3",
"vite": "^6.1.0",
"vite-plugin-dts": "^4.5.0",
"vite-plugin-virtual": "^0.3.0",
diff --cc packages/harper.js/src/Linter.test.ts
index b9eb1ac46,e7da44f23..6bec3a0fd
--- a/packages/harper.js/src/Linter.test.ts
+++ b/packages/harper.js/src/Linter.test.ts
@@@ -69,10 -72,10 +69,10 @@@ for (const [linterName, Linter] of Obje
});
test(`${linterName} contains configuration option for repetition`, async () => {
- const linter = new Linter();
+ const linter = new Linter({ binary });
const lintConfig = await linter.getLintConfig();
- expect(lintConfig).toHaveProperty('repeated_words');
+ expect(lintConfig).toHaveProperty('RepeatedWords');
});
test(`${linterName} can both get and set its configuration`, async () => {
diff --cc packages/harper.js/src/Linter.ts
index 0ee052872,609a621c0..d5bc9ddf0
--- a/packages/harper.js/src/Linter.ts
+++ b/packages/harper.js/src/Linter.ts
@@@ -64,9 -63,11 +64,16 @@@ export default interface Linter
/** Clear records of all previously ignored lints. */
clearIgnoredLints(): Promise<void>;
+
+ /** Import words into the dictionary. This is a significant operation, so try to batch words. */
+ importWords(words: string[]): Promise<void>;
+
+ /** Export all added words from the dictionary. Note that this will NOT export anything from the curated dictionary,
+ * only words from previous calls to `this.importWords`. */
+ exportWords(): Promise<string[]>;
}
+
+export interface LinterInit {
+ /** The module or path to the WebAssembly binary. */
+ binary: BinaryModule;
+}
diff --cc packages/harper.js/src/LocalLinter.ts
index 265f75a82,fd98d23fb..41050bd74
--- a/packages/harper.js/src/LocalLinter.ts
+++ b/packages/harper.js/src/LocalLinter.ts
@@@ -101,7 -120,20 +101,19 @@@ export default class LocalLinter implem
}
async clearIgnoredLints(): Promise<void> {
- await this.initialize();
-
- return this.inner!.clear_ignored_lints();
+ const inner = await this.inner;
+ inner.clear_ignored_lints();
}
+
+ async importWords(words: string[]): Promise<void> {
+ await this.initialize();
+
+ return this.inner!.import_words(words);
+ }
+
+ async exportWords(): Promise<string[]> {
+ await this.initialize();
+
+ return this.inner!.export_words();
+ }
}
diff --cc packages/package.json
index 974f6b6ab,aa7615de7..86cbe7f0f
--- a/packages/package.json
+++ b/packages/package.json
@@@ -11,11 -12,10 +12,11 @@@
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-svelte": "^2.46.1",
- "prettier": "^3.4.2",
+ "prettier": "^3.5.3",
"prettier-plugin-svelte": "^3.0.3",
"@typescript-eslint/eslint-plugin": "^8.18.1",
- "@typescript-eslint/parser": "^8.18.1"
+ "@typescript-eslint/parser": "^8.18.1",
+ "typescript": "^5.7.2"
},
- "packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
+ "packageManager": "[email protected]"
}
diff --cc packages/web/package.json
index 5d2dfbfca,803ec295a..ce44c9095
--- a/packages/web/package.json
+++ b/packages/web/package.json
@@@ -23,11 -23,11 +23,11 @@@
"svelte-check": "^4.1.1",
"tailwindcss": "^3.3.3",
"tslib": "^2.4.1",
+ "vite": "^6.1.0",
"typescript": "^5.7.3",
- "vite": "^6.0.9",
"vite-plugin-pwa": "^0.21.1",
- "vite-plugin-top-level-await": "^1.4.4",
+ "vite-plugin-top-level-await": "^1.5.0",
- "vite-plugin-wasm": "^3.3.0"
+ "vite-plugin-wasm": "^3.4.1"
},
"type": "module",
"dependencies": {
diff --cc packages/web/src/routes/docs/rules/+page.svelte
index e30796b09,67a26bd1f..3bc0a8f3e
--- a/packages/web/src/routes/docs/rules/+page.svelte
+++ b/packages/web/src/routes/docs/rules/+page.svelte
@@@ -6,23 -14,16 +14,16 @@@
title: 'Rules'
};
- let info: Record<string, string> = $state({});
- let titles: Record<string, string> = $state({});
+ let descriptions: Record<string, string> = $state({});
+ let default_config: LintConfig = $state({});
- let linter = new LocalLinter();
+ let linter = new LocalLinter({ binary });
linter.getLintDescriptions().then(async (v) => {
- info = v;
-
- for (let key of Object.keys(info)) {
- titles[key] = await makeTitleCase(key);
- console.log(key, titles[key]);
- }
+ descriptions = v;
+ });
+ linter.getDefaultLintConfig().then(async (v) => {
+ default_config = v;
});
-
- /** Make a snake case string title case. */
- function makeTitleCase(snakeCase: string): Promise<string> {
- return linter.toTitleCase(snakeCase.replaceAll('_', ' '));
- }
</script>
<p>This page is an incomplete list of the various grammatical rules Harper checks for.</p>
diff --cc packages/yarn.lock
index 9e254a151,1d362ac04..3258ebdb3
--- a/packages/yarn.lock
+++ b/packages/yarn.lock
@@@ -5130,12 -10079,18 +10079,22 @@@ gzip-size@^6.0.0
dependencies:
duplexer "^0.1.2"
+ handle-thing@^2.0.0:
+ version "2.0.1"
+ resolved "https://registry.yarnpkg.com/handle-thing/-/handle-thing-2.0.1.tgz#857f79ce359580c340d43081cc648970d0bb234e"
+ integrity sha512-9Qn4yBxelxoh2Ow62nP+Ka/kMnOXRi8BXnRaUwezLNhqelnN49xKz4F/dPP8OYLxLxq6JDtZb2i9XznUQbNPTg==
+
+ hard-rejection@^2.1.0:
+ version "2.1.0"
+ resolved "https://registry.yarnpkg.com/hard-rejection/-/hard-rejection-2.1.0.tgz#1c6eda5c1685c63942766d79bb40ae773cecd883"
+ integrity sha512-VIZB+ibDhx7ObhAe7OVtoEbuP4h/MuOTHJ+J8h/eBXotJYl0fBgR72xDFCKgIh22OJZIOVNxBMWuhAr10r8HdA==
+
+"harper-wasm@link:../harper-wasm/pkg":
+ version "0.0.0"
+ uid ""
+
"harper.js@link:harper.js":
- version "0.20.0"
+ version "0.24.0"
has-bigints@^1.0.2:
version "1.1.0"
@@@ -8710,12 -16929,19 +16933,19 @@@ typed-rest-client@^1.8.4
tunnel "0.0.6"
underscore "^1.12.1"
- version "5.7.2"
- resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.7.2.tgz#3169cf8c4c8a828cde53ba9ecb3d2b1d5dd67be6"
- integrity sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==
+ typed.js@^2.1.0:
+ version "2.1.0"
+ resolved "https://registry.yarnpkg.com/typed.js/-/typed.js-2.1.0.tgz#b97a06111a5f57d6a59acfdd36d4f9b891ee13b4"
+ integrity sha512-bDuXEf7YcaKN4g08NMTUM6G90XU25CK3bh6U0THC/Mod/QPKlEt9g/EjvbYB8x2Qwr2p6J6I3NrsoYaVnY6wsQ==
+
+ typedarray-to-buffer@^3.1.5:
+ version "3.1.5"
+ resolved "https://registry.yarnpkg.com/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz#a97ee7a9ff42691b9f783ff1bc5112fe3fca9080"
+ integrity sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==
+ dependencies:
+ is-typedarray "^1.0.0"
- typescript@^5.7.2, typescript@^5.7.3:
[email protected], typescript@~5.7.3:
[email protected], typescript@^5.7.2:
version "5.7.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.7.3.tgz#919b44a7dbb8583a9b856d162be24a54bf80073e"
integrity sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==
@@@ -9028,13 -17378,13 +17382,13 @@@ vite-plugin-wasm@^3.4.1
resolved "https://registry.yarnpkg.com/vite-plugin-wasm/-/vite-plugin-wasm-3.4.1.tgz#62b546ac7e25cc2a0e7b1331ed5c4ba1dd71b743"
integrity sha512-ja3nSo2UCkVeitltJGkS3pfQHAanHv/DqGatdI39ja6McgABlpsZ5hVgl6wuR8Qx5etY3T5qgDQhOWzc5RReZA==
-"vite@^5.0.0 || ^6.0.0", vite@^6.0.9, vite@^6.1.0:
+"vite@^5.0.0 || ^6.0.0", vite@^6.1.0:
- version "6.1.0"
- resolved "https://registry.yarnpkg.com/vite/-/vite-6.1.0.tgz#00a4e99a23751af98a2e4701c65ba89ce23858a6"
- integrity sha512-RjjMipCKVoR4hVfPY6GQTgveinjNuyLw+qruksLDvA5ktI1150VmcMBKmQaEWJhg/j6Uaf6dNCNA0AfdzUb/hQ==
+ version "6.2.0"
+ resolved "https://registry.yarnpkg.com/vite/-/vite-6.2.0.tgz#9dcb543380dab18d8384eb840a76bf30d78633f0"
+ integrity sha512-7dPxoo+WsT/64rDcwoOjk76XHj+TqNTIvHKcuMQ1k4/SeHDaQt5GFAeLYzrimZrMpn/O6DtdI03WUjdxuPM0oQ==
dependencies:
- esbuild "^0.24.2"
- postcss "^8.5.1"
+ esbuild "^0.25.0"
+ postcss "^8.5.3"
rollup "^4.30.1"
optionalDependencies:
fsevents "~2.3.3"
@@@ -9098,9 -17448,57 +17452,54 @@@ [email protected]
integrity sha512-Ld1VelNuX9pdF39h2Hgaeb5hEZM2Z3jUrrMgWQAu82jMtZp7p3vJT3BzToKtZI7NgQssZje5o0zryOrhQvzQAg==
vscode-uri@^3.0.8:
- version "3.0.8"
- resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-3.0.8.tgz#1770938d3e72588659a172d0fd4642780083ff9f"
- integrity sha512-AyFQ0EVmsOZOlAnxoFOGOq1SQDWAB7C6aqMGS23svWAllfOaxbuFvcT8D1i8z3Gyn8fraVeZNNmN6e9bxxXkKw==
+ version "3.1.0"
+ resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-3.1.0.tgz#dd09ec5a66a38b5c3fffc774015713496d14e09c"
+ integrity sha512-/BpdSx+yCQGnCvecbyXdxHDkuk55/G3xwnC0GqY4gmQ3j+A+g8kzzgB4Nk/SINjqn6+waqw3EgbVF2QKExkRxQ==
+
+ w3c-xmlserializer@^4.0.0:
+ version "4.0.0"
+ resolved "https://registry.yarnpkg.com/w3c-xmlserializer/-/w3c-xmlserializer-4.0.0.tgz#aebdc84920d806222936e3cdce408e32488a3073"
+ integrity sha512-d+BFHzbiCx6zGfz0HyQ6Rg69w9k19nviJspaj4yNscGjrHu94sVP+aRm75yEbCh+r2/yR+7q6hux9LVtbuTGBw==
+ dependencies:
+ xml-name-validator "^4.0.0"
+
+ wait-on@^8.0.1:
+ version "8.0.2"
+ resolved "https://registry.yarnpkg.com/wait-on/-/wait-on-8.0.2.tgz#0c7929abf7c5e625b733e992a9c0bd8b7691afe3"
+ integrity sha512-qHlU6AawrgAIHlueGQHQ+ETcPLAauXbnoTKl3RKq20W0T8x0DKVAo5xWIYjHSyvHxQlcYbFdR0jp4T9bDVITFA==
+ dependencies:
+ axios "^1.7.9"
+ joi "^17.13.3"
+ lodash "^4.17.21"
+ minimist "^1.2.8"
+ rxjs "^7.8.1"
+
+ walker@^1.0.8:
+ version "1.0.8"
+ resolved "https://registry.yarnpkg.com/walker/-/walker-1.0.8.tgz#bd498db477afe573dc04185f011d3ab8a8d7653f"
+ integrity sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ==
+ dependencies:
+ makeerror "1.0.12"
+
-"wasm@link:../harper-wasm/pkg":
- version "0.0.0"
-
+ watchpack@^2.4.1:
+ version "2.4.2"
+ resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.4.2.tgz#2feeaed67412e7c33184e5a79ca738fbd38564da"
+ integrity sha512-TnbFSbcOCcDgjZ4piURLCbJ3nJhznVh9kw6F6iokjiFPl8ONxe9A6nMDVXDiNbrSfLILs6vB07F7wLBrwPYzJw==
+ dependencies:
+ glob-to-regexp "^0.4.1"
+ graceful-fs "^4.1.2"
+
+ wbuf@^1.1.0, wbuf@^1.7.3:
+ version "1.7.3"
+ resolved "https://registry.yarnpkg.com/wbuf/-/wbuf-1.7.3.tgz#c1d8d149316d3ea852848895cb6a0bfe887b87df"
+ integrity sha512-O84QOnr0icsbFGLS0O3bI5FswxzRr8/gHwWkDlQFskhSPryQXvrTMxjxGP4+iWYoauLoBvfDpkrOauZ+0iZpDA==
+ dependencies:
+ minimalistic-assert "^1.0.0"
+
+ web-vitals@^4.2.1:
+ version "4.2.4"
+ resolved "https://registry.yarnpkg.com/web-vitals/-/web-vitals-4.2.4.tgz#1d20bc8590a37769bd0902b289550936069184b7"
+ integrity sha512-r4DIlprAGwJ7YM11VZp4R884m0Vmgr6EAKe3P+kO0PPj3Unqyvv59rczf6UiGcb9Z8QxZVcqKNwv/g0WNdWwsw==
webidl-conversions@^4.0.2:
version "4.0.2"