Skip to content

feat: show warning on pkg fetch error#28

Open
nitodeco wants to merge 2 commits intonpmx-dev:mainfrom
nitodeco:feat/ui-feedback-on-lookup-failure
Open

feat: show warning on pkg fetch error#28
nitodeco wants to merge 2 commits intonpmx-dev:mainfrom
nitodeco:feat/ui-feedback-on-lookup-failure

Conversation

@nitodeco
Copy link
Collaborator

@nitodeco nitodeco commented Feb 5, 2026

Resolves #19.

Shows warning when package can't be found:
datprotalav

@coderabbitai
Copy link

coderabbitai bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

The hover provider in src/providers/hover/npmx.ts was updated to better handle missing package metadata and JSR specifiers. New behaviour: when getPackageInfo(name) is falsy and the version is a JSR specifier, the hover now returns a jsr.io link and a not-on-npmx warning; otherwise it returns a generic "Unable to fetch package information" hover. Imports and URL helpers were changed: npmPacakgeUrl renamed to npmPackageUrl, jsrPackageUrl added, and isJsrSpecifier introduced. Provenance links now use npmPackageUrl(name, coercedVersion). No public API signature changes.

Possibly related PRs

Suggested reviewers

  • 9romise
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The PR description directly references issue #19 and includes an image showing the warning message displayed when package fetch fails, which aligns with the changeset.
Linked Issues check ✅ Passed The PR addresses issue #19 by implementing hover feedback when package lookup fails, showing 'Unable to fetch package information' warning and JSR link support for unsupported packages.
Out of Scope Changes check ✅ Passed All changes are directly scoped to resolving issue #19: adding JSR package URL support, implementing hover fallback warnings, and adding JSR specifier detection utilities.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

Copy link
Member

@9romise 9romise left a comment

Choose a reason for hiding this comment

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

Good job! I think we could also prompt users to visit https://jsr.io when a jsr:‑style specifier is detected.

@nitodeco
Copy link
Collaborator Author

nitodeco commented Feb 5, 2026

@9romise wdyt?

Pasted Graphic 1

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Comment on lines +20 to +25
export function jsrPackageUrl(name: string, version: string): string {
const jsrVersionRange = version.replace(/^jsr:/, '')
const jsrVersion = extractVersion(jsrVersionRange)

return `https://jsr.io/${name}@${jsrVersion}`
}
Copy link

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:

# Find the extractVersion function
rg -A 5 "function extractVersion|const extractVersion|export.*extractVersion" --type ts

Repository: npmx-dev/vscode-npmx

Length of output: 674


🏁 Script executed:

# Locate the package.ts file mentioned in the comment
find . -name "package.ts" -type f

Repository: npmx-dev/vscode-npmx

Length of output: 113


🏁 Script executed:

# Get the context around the jsrPackageUrl function
rg -B 5 -A 10 "jsrPackageUrl" --type ts

Repository: npmx-dev/vscode-npmx

Length of output: 2596


🏁 Script executed:

# Look for test files related to extractVersion or jsrPackageUrl
find . -name "*.test.*" -o -name "*.spec.*" | head -20

Repository: npmx-dev/vscode-npmx

Length of output: 1984


🏁 Script executed:

# Search for JSR specifier examples in the codebase
rg "jsr:" --type ts --type json -B 2 -A 2

Repository: npmx-dev/vscode-npmx

Length of output: 757


🏁 Script executed:

# Check if there's any documentation or comments about JSR format
rg -i "jsr.*version|version.*jsr" --type ts -B 2 -A 2

Repository: npmx-dev/vscode-npmx

Length of output: 1482


🌐 Web query:

JSR JavaScript Registry version specifier format semver ranges

💡 Result:

JSR specifier format

JSR module specifiers must be of the form: jsr:@<scope>/<name>@<version>/<path> (or with an optional extra slash after jsr:: jsr:/@<scope>/<name>@<version>/<path>). The /path part is optional if you’re importing the package entrypoint. [1]

Examples:

  • import { camelCase } from "jsr:@luca/cases@^1.0.1"; [2]
  • Import map / install entries commonly look like jsr:@std/path@^1.0.3. [3]

What <version> can be (SemVer ranges)

JSR resolves versions using Semantic Versioning and allows a semver range anywhere you can write a version (specifier, import maps, package.json dependencies). Tools then pick the latest version that satisfies all constraints. [2]

Common allowed forms include:

  • Exact: @1.2.3
  • Major-only / minor-only partials: @1 or @1.0 [2]
  • Caret / tilde: @^1.0.1, @~1.2.0 [2]
  • Comparators: @>=1.0.0, @<2.0.0, etc. [4]
  • Hyphen ranges: @1.2.3 - 2.3.4 [4]
  • AND by whitespace: @>=1.0.0 <2.0.0 [4]
  • OR with ||: @<1.0.0 || >=2.0.0 [4]
  • Wildcards / x-ranges: @1.x, @1.*, etc. [4]

(That range syntax matches the semver range grammar used by Deno’s @std/semver implementation.) [4]

Sources: [1] JSR troubleshooting (invalid specifier format); [2] JSR “Using packages” docs; [3] Deno std docs showing JSR ranges in import maps; [4] @std/semver range grammar on JSR.


Minor: extractVersion handles only caret and tilde prefixes, not other semver range operators.

The extractVersion utility only strips ^ and ~ range prefixes. JSR specifiers can use other semver operators (e.g., jsr:>=0.189.1, jsr:<1.0.0, jsr:<1.0.0 || >=2.0.0), which would result in malformed URLs.

This is likely acceptable given that caret and tilde are the predominant range specifiers in practice, but worth noting for completeness.

Copy link
Member

@9romise 9romise left a comment

Choose a reason for hiding this comment

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

Nice! Thank you! ❤️

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.

No hover feedback when package lookup fails (e.g. @deno/doc)

2 participants