8000 feat(wasm): expose grit search functions to wasm by dyc3 · Pull Request #8911 · biomejs/biome · GitHub
[go: up one dir, main page]

Skip to content

feat(wasm): expose grit search functions to wasm - #8911

Merged
ematipico merged 1 commit into
mainfrom
dyc3/expose-search-to-wasm
Jan 30, 2026
Merged

ematipico merged 1 commit into
mainfrom
dyc3/expose-search-to-wasm

Conversation

@dyc3
@dyc3 dyc3 commented Jan 29, 2026 •
Copy link
Copy Markdown
Contributor

Summary

We need to expose these functions in order to integrate it into the playground.

generated by glm-4.7

Test Plan

Tests for the js-api are in the next PR in the stack, which also tests this.

Docs

@changeset-bot
changeset-bot Bot commented Jan 29, 2026 •
Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: ef02264

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

dyc3 commented Jan 29, 2026 •
Copy link
Copy Markdown
Contributor Author

@dyc3
dyc3 requested review from a team January 29, 2026 20:35
@dyc3
dyc3 marked this pull reques 10000 t as ready for review January 29, 2026 20:38
@coderabbitai
coderabbitai Bot commented Jan 29, 2026 •
Copy link
Copy Markdown
Contributor

Walkthrough

Three new pattern-related methods were added to the biome_wasm crate's public Workspace API: parsePattern, searchPattern, and dropPattern. Each method accepts corresponding parameter types (ParsePatternParams, SearchPatternParams, DropPatternParams), which are now exposed in the public module imports. The implementations delegate to the underlying inner workspace methods via serde_wasm_bindgen conversions, enabling WASM consumers to interact with pattern operations. The net change amounts to 34 lines added and 6 removed.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: exposing grit search functions to WebAssembly with three new WASM-exposed methods (parsePattern, searchPattern, dropPattern).
Description check ✅ Passed The description is related to the changeset, explaining the motivation (playground integration) and noting that tests are planned in a follow-up PR.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @.changeset/grit-search-bindings.md:
- Around line 12-23: The example uses parsePattern as if it returns a raw
patternId, but parsePattern actually returns a Promise<ParsePatternResult>
object containing a patternId property; update the example to await and
destructure the result (e.g., const { patternId } = await
Biome.parsePattern(...) or from biome.parsePattern(...)) and then pass that
patternId into biome.searchPattern and biome.dropPattern so the calls use the
correct value type.

Comment thread .changeset/grit-search-bindings.md Outdated
Comment on lines +12 to +23
```typescript
const biome = await Biome.create({ distribution: Distribution.BUNDLER });
const projectKey = biome.openProject().projectKey;

// Parse a GritQL pattern
const patternId = biome.parsePattern("const $x = 1;", "JavaScript");

// Search for matches
const matches = biome.searchPattern(projectKey, "test.js", fileContent, patternId);

// Clean up
biome.dropPattern(patternId);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for parsePattern method definition and return type hints
rg -n "parsePattern" -g '*.{ts,js,tsx,jsx}' -B 2 -A 5 | head -100

Repository: biomejs/biome

Length of output: 1590


🏁 Script executed:

#!/bin/bash
# Look for interface/type definitions related to pattern parsing
rg -n "IParsePatternResult|ParsePatternResult|patternId" -g '*.{ts,js,tsx,jsx}' -B 2 -A 2 | head -150

Repository: biomejs/biome

Length of output: 1135


🏁 Script executed:

#!/bin/bash
# Check if there's documentation or implementation in the changeset area
find . -name "*.md" -o -name "*.ts" -o -name "*.js" | grep -i changeset | head -20
ls -la .changeset/ 2>/dev/null || echo "Changeset directory listing failed"

Repository: biomejs/biome

Length of output: 1277


Fix the example to match the API return type.

parsePattern returns Promise<ParsePatternResult> where ParsePatternResult is an object with a patternId property. The example should destructure the result:

Suggested fix
-const patternId = biome.parsePattern("const $x = 1;", "JavaScript");
+const { patternId } = await biome.parsePattern("const $x = 1;", "JavaScript");
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
```typescript
const biome = await Biome.create({ distribution: Distribution.BUNDLER });
const projectKey = biome.openProject().projectKey;
// Parse a GritQL pattern
const patternId = biome.parsePattern("const $x = 1;", "JavaScript");
// Search for matches
const matches = biome.searchPattern(projectKey, "test.js", fileContent, patternId);
// Clean up
biome.dropPattern(patternId);
🤖 Prompt for AI Agents
In @.changeset/grit-search-bindings.md around lines 12 - 23, The example uses
parsePattern as if it returns a raw patternId, but parsePattern actually returns
a Promise<ParsePatternResult> object containing a patternId property; update the
example to await and destructure the result (e.g., const { patternId } = await
Biome.parsePattern(...) or from biome.parsePattern(...)) and then pass that
patternId into biome.searchPattern and biome.dropPattern so the calls use the
correct value type.

@dyc3
dyc3 marked this pull request as draft January 29, 2026 20:56
@dyc3
dyc3 force-pushed the dyc3/expose-search-to-wasm branch from 62effcf to ef02264 Compare January 29, 2026 21:10
@dyc3
dyc3 marked this pull request as ready for review January 29, 2026 21:22
@ematipico
ematipico merged commit 9dc99cc into main Jan 30, 2026
13 checks passed
@ematipico
ematipico deleted the dyc3/expose-search-to-wasm branch January 30, 2026 07:17
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.

2 participants

0