Skip to content

docs(harper.js): add Chrome extension example and docs page - #3929

Open
leepokai wants to merge 2 commits into
Automattic:masterfrom
leepokai:docs/harperjs-chrome-extension-example
Open

docs(harper.js): add Chrome extension example and docs page#3929
leepokai wants to merge 2 commits into
Automattic:masterfrom
leepokai:docs/harperjs-chrome-extension-example

Conversation

@leepokai

Copy link
Copy Markdown

Note

Per Harper's policy on agent PRs: this PR was authored with an LLM-based agent (Claude Code), human-directed and reviewed. End-to-end verification is described below.

Closes #3628

What

  • New example packages/harper.js/examples/chrome-extension/: a minimal Manifest V3 extension whose popup lints a textarea with harper.js and shows the bundled version — the "tiny example… opens a popup… and displays the harper-core version" asked for in Docs: Add an intro for how to use harper.js inside a Chrome extension #3628.
  • New docs page /docs/harperjs/chrome-extension covering the three MV3 pitfalls that make this "next level complicated":
    1. Extensions may not load remote code, so the CDN approach doesn't apply — build.js copies the harper.js dist into the extension, and binaryInlined avoids a separate fetch for the wasm binary.
    2. The default extension CSP blocks WebAssembly compilation — the manifest opts in with wasm-unsafe-eval.
    3. WorkerLinter spawns its Web Worker from a blob URL, which the extension CSP blocks — so the example uses LocalLinter.
  • Sidebar entry under harper.js after "CDN" in packages/web/vite.config.ts.

Verification

  • Built the example against published harper.js@2.7.0 and loaded the resulting dist/ as a real unpacked extension in Chromium (Playwright, --load-extension):
    • popup loads with zero page/console errors, i.e. the wasm engine compiles under the manifest CSP
    • the intentionally flawed sample text yields 3 lints (two "Incorrect indefinite article", one proper-noun hint)
    • the footer renders harper.js 2.7.0
  • biome check clean on the new files.

The version question raised in the issue is addressed at the bottom of the docs page: there is no runtime API exposing the engine version, but harper.js and harper-core are versioned together (both currently 2.7.0), so the package version identifies the engine.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docs: Add an intro for how to use harper.js inside a Chrome extension

1 participant