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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@shortround/core

v0.2.2

Published

Core library for ShortRound, providing the main hooks and functionality for command palette and voice interaction.

Downloads

195

Readme

@shortround/core

Core library for ShortRound, providing the main hooks and functionality for command palette and sidekick interaction.

Installation

npm install @shortround/core

This package provides the headless logic - you'll either need

  • a UI package like @shortround/mui for the visual components.
  • provide your own components (see below)

Core Hooks

useShortRound

Manages the list of intentions and fuzzy matching of user input.

import { useShortRound } from '@shortround/core';

const { 
  inputValue, 
  onInputChange, 
  intentions, 
  dispatch, 
  reset, 
  back,
  inputMessage,
  dispatchedStack 
} = useShortRound({ 
  defaultIntentions 
});

Parameters:

  • defaultIntentions: Intention[] - Initial set of intentions to display

Returns:

  • inputValue: string - Current input text
  • onInputChange: (value: string) => void - Update input and trigger fuzzy matching
  • intentions: Intention[] - Filtered intentions based on input
  • dispatch: (intentionId: string) => Promise<IntentionActionResult> - Execute an intention
  • reset: () => Promise<IntentionActionResult> - Reset to default intentions
  • back: () => Promise<IntentionActionResult> - Go back to previous intention set
  • inputMessage?: { type: string; text: string } - Validation message to display
  • dispatchedStack: Intention[] - History of executed intentions

useSidekick

UI controller that manages the popover (overlay) and sidekick drawer.

import { useSidekick } from '@shortround/core';

const {
  isOpen,
  isSidecarOpen,
  onOpen,
  onClose,
  setSidecarRenderer,
  closeSidecar,
  height,
  anchorOrigin,
  cycleAnchorOrigin,
  // ... other properties
} = useSidekick({
  store, // optional: external store
  initial: { size: 'medium' } // optional: initial state
});

Parameters:

  • store?: SidekickStore - External store instance
  • initial?: Partial<SidekickStoreState> - Initial state overrides

Returns: Full sidekick state and control methods (see TypeScript definitions for complete interface)

Intention Object

{
  id: 'unique-identifier',
  title: 'Display Name',
  group: 'Category Name',
  aliases: ['search', 'terms'], // optional
  icon: 'icon-name', // optional
  disabled: false, // optional
  validate: (input) => ({ valid: true, message: 'Optional error' }), // optional
  action: async (input) => {
    // Your logic here
    return {
      intentions: newIntentions, // optional: new intention set
      shouldReset: false, // optional: close palette
      disableInputMatching: false, // optional: disable fuzzy search
      includeRevertIntentions: [RevertIntentionIds.BACK], // optional: add back/cancel
      message: 'Success!', // optional: toast notification
      sideEffects: {
        sidecarRenderer: () => <MyComponent /> // optional: show sidekick content
      }
    };
  }
}

System Intentions

ShortRound provides built-in system intentions for navigation:

import { RevertIntentionIds, makeRevertIntentionsFor } from '@shortround/core';

// Available system intentions
RevertIntentionIds.BACK   // Go back to previous intention set
RevertIntentionIds.RESET  // Reset to default intentions

// Include them in your action results
return {
  intentions: myIntentions,
  includeRevertIntentions: [RevertIntentionIds.BACK, RevertIntentionIds.RESET]
};

Sidekick Store

For advanced usage, you can create and manage the sidekick store manually:

import { createSidekickStore, SidekickStoreProvider } from '@shortround/core';

const store = createSidekickStore({
  size: 'full',
  anchorOrigin: 'center',
  commandWidth: '50vw'
});

function App() {
  return (
    <SidekickStoreProvider store={store}>
      {/* Your components */}
    </SidekickStoreProvider>
  );
}

Constants

import { AnchorPositions, Sizes } from '@shortround/core';

// Available anchor positions
AnchorPositions.CENTER, AnchorPositions.TOP_LEFT, etc.

// Available sizes
Sizes.COMPACT, Sizes.MEDIUM, Sizes.FULL

TypeScript Support

This package includes full TypeScript definitions. Key types:

  • Intention - Intention object structure
  • IntentionActionResult - Action return type
  • SidekickStore - Store interface
  • UseShortRoundResult - Hook return type
  • UseSidekickResult - Hook return type
  • SidekickComponents - Interface for custom UI implementations

Custom UI Components

While we provide pre-built UI packages like @shortround/mui, you can create your own SidekickComponents implementation. The SidekickComponents interface defines the required component structure:

const MySidekickComponents = {
  IntentionPalette: {
    Frame: ({ height, children }) => <div style={{ height }}>{children}</div>,
    Input: ({ inputValue, onInputChange, inputMessage }) => (
      <input 
        value={inputValue} 
        onChange={(e) => onInputChange(e.target.value)}
        placeholder="Search..."
      />
    ),
    Item: ({ intention, onSelect }) => (
      <button onClick={() => onSelect(intention.id)}>
        {intention.title}
      </button>
    ),
    Group: ({ name }) => <div className="group-header">{name}</div>,
    NoMatches: ({ inputValue }) => <div>No matches for "{inputValue}"</div>
  },
  Sidekick: {
    Frame: ({ height, commandWidth, children }) => (
      <div style={{ height, width: commandWidth }}>{children}</div>
    ),
    ControlBar: ({ title, onClose, setSize, size, cycleAnchorOrigin }) => (
      <div>
        <span>{title}</span>
        <button onClick={onClose}>×</button>
        <button onClick={cycleAnchorOrigin}>⌖</button>
        <select value={size} onChange={(e) => setSize(e.target.value)}>
          <option value="compact">Compact</option>
          <option value="medium">Medium</option>
          <option value="full">Full</option>
        </select>
      </div>
    ),
    Popover: ({ anchorPosition, height, totalWidth, children }) => (
      <div style={{ position: 'fixed', ...anchorPosition, height, width: totalWidth }}>
        {children}
      </div>
    )
  },
  SidecarContent: ({ isOpen, renderSidecar, height }) => (
    <div style={{ height, display: isOpen ? 'block' : 'none' }}>
      {renderSidecar?.()}
    </div>
  ),
  ThemeProvider: ({ children }) => children
};

// Use your custom components
<ShortRoundSidekick 
  SidekickComponents={MySidekickComponents}
  defaultIntentions={intentions}
/>

For a complete implementation example, see the @shortround/mui package source code which demonstrates proper component integration with Material-UI.

Other Packages

License

MIT