npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@sourcegraph/codeintellify

v7.4.0

Published

Adds code intelligence to code views on the web

Downloads

93

Readme

CodeIntellify

build codecov code style: prettier semantic-release sourcegraph: search

This library manages all of the inputs (mouse/keyboard events, location changes, hover information, and hover actions) necessary to display hover tooltips on with a code view. All together, this makes it easier to add code intelligence to code views on the web. Used in Sourcegraph.

What it does

  • Listens to hover and click events on the code view
  • On mouse hovers, determines the line+column position, performs a hover request, and renders it in a nice tooltip overlay at the token
  • Shows actions in the hover
  • When clicking a token, pins the tooltip to that token
  • Highlights the hovered token

You need to provide your own UI component (referred to as the HoverOverlay) that actually displays this information and exposes these actions to the user.

Usage

  • Call createHoverifier() to create a Hoverifier object (there should only be one on the page, to have only one HoverOverlay shown).
  • The Hoverifier exposes an Observable hoverStateUpdates that a consumer can subscribe to, which emits all data needed to render the HoverOverlay
  • For each code view on the page, call hoverifier.hoverify(), passing the position events coming from findPositionsFromEvents().
  • hoverify() returns a Subscription that will "unhoverify" the code view again if unsubscribed from

Development

yarn
yarn test

# Helpful options:
yarn test -- --single-run      # Don't rerun on changes
yarn test -- --browsers Chrome # Only run in Chrome

Development is done by running tests. Karma is used to run Mocha tests in the browser. You can debug by opening http://localhost:9876/debug.html in a browser while the test running is active. The tests will rerun automatically when files are changed.

You can run specific tests by adding .only to describe or it calls.

Releases

Releases are done automatically in CI when commits are merged into master by analyzing Conventional Commit Messages. After running yarn, commit messages will be linted automatically when committing. You may have to rebase a branch before merging to ensure it has a proper commit history.

Glossary

| Term | Definition | | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Code view | The DOM element that contains all the line elements | | Line number element | The DOM element that contains the line number label for that line | | Code element | The DOM element that contains the code for one line | | Diff part | The part of the diff, either base, head or both (if the line didn't change). Each line belongs to one diff part, and therefor to a different commit ID and potentially different file path. | | Hover overlay | Also called tooltip | | hoverify | To attach all the listeners needed to a code view so that it will display overlay on hovers and clicks. | | unhoverify | To unsubscribe from the Subscription returned by hoverifier.hoverify(). Removes all event listeners from the code view again and hides the hover overlay if it was triggered by the unhoverified code view. |