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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cytoscape-web/api-types

v1.0.0-beta.2

Published

TypeScript type declarations for the Cytoscape Web App API

Readme

@cytoscape-web/api-types

TypeScript type declarations for the Cytoscape Web App API.

Install this package in your plugin app to get full IDE support — hover types, parameter names, and completions — for all cyweb/* Module Federation imports and the window.CyWebApi global, without needing the host repository.

Installation

npm install --save-dev @cytoscape-web/api-types

Setup

Add the package to your tsconfig.json:

{
  "compilerOptions": {
    "typeRoots": ["./node_modules/@types", "./node_modules/@cytoscape-web"]
  }
}

That's it. No imports needed — global augmentations for window.CyWebApi and typed window.addEventListener overloads are active automatically.

What's included

| Export | Description | |--------|-------------| | CyWebApiType | Type of window.CyWebApi (10 domain API objects) | | ElementApi | Create/delete nodes and edges, visual bypasses, graph traversal queries | | NetworkApi | Create, delete, and switch networks | | SelectionApi | Read and modify node/edge selection state | | ViewportApi | Pan, zoom, and fit the viewport | | TableApi | Read and write node/edge attribute tables | | VisualStyleApi | Read and set visual style properties and bypasses | | LayoutApi | Run and stop layout algorithms | | ExportApi | Export networks to CX2, PNG, and SVG | | WorkspaceApi | Read workspace and network summary metadata | | ContextMenuApi | Register custom items in the network context menu | | AppContextApis | Per-app API shape passed to mount() (extends CyWebApiType) | | ResourceApi | Register panels and menu items at runtime | | ResourceDeclaration | Declarative resource entry for CyAppWithLifecycle.resources | | ApiResult<T> | Discriminated union returned by all API functions | | ApiErrorCode | Enum of all possible error codes | | CyWebEvents | Typed event detail shapes for all window events | | Model types | IdType, Network, Node, Edge, Table, VisualStyle, … |

Ambient module declarations for all cyweb/* Module Federation remotes are also bundled, so imports like import { useElementApi } from 'cyweb/ElementApi' resolve correctly in TypeScript.

Usage examples

Declarative resource registration (recommended)

import { lazy } from 'react'
import { CyAppWithLifecycle } from 'cyweb/ApiTypes'

export const MyApp: CyAppWithLifecycle = {
  id: 'myApp',
  name: 'My App',
  version: '1.0.0',
  apiVersion: '1.0',

  // Panels and menu items — host registers these automatically
  resources: [
    {
      slot: 'right-panel',
      id: 'MainPanel',
      title: 'My Panel',
      component: lazy(() => import('./components/MainPanel')),
    },
    {
      slot: 'apps-menu',
      id: 'QuickAction',
      title: 'Quick Action',
      component: lazy(() => import('./components/QuickAction')),
      closeOnAction: true,
    },
  ],

  // Context menus need apis access, so they go in mount()
  mount({ apis }) {
    apis.contextMenu.addContextMenuItem({
      label: 'Highlight node',
      targetTypes: ['node'],
      handler: ({ id, networkId }) => {
        apis.visualStyle.setBypass(networkId, 'NODE_BACKGROUND_COLOR', { [id]: '#ff0000' })
      },
    })
  },
}

Module Federation (React component)

import { useElementApi } from 'cyweb/ElementApi'
import { useWorkspaceApi } from 'cyweb/WorkspaceApi'
import { useCyWebEvent } from 'cyweb/EventBus'

function MyPanel() {
  const element = useElementApi()
  const workspace = useWorkspaceApi()

  useCyWebEvent('network:switched', ({ networkId }) => {
    console.log('switched to', networkId)
  })

  const handleAdd = () => {
    const net = workspace.getCurrentNetworkId()
    if (!net.success) return
    const result = element.createNode(net.data.networkId, [100, 200])
    if (result.success) {
      console.log('created node', result.data.nodeId)
    }
  }
}

Per-app context in plugin components

import { useAppContext } from 'cyweb/AppIdContext'

function MyComponent() {
  const ctx = useAppContext()
  if (!ctx) return null

  // ctx.apis has all 10 domain APIs + resource + contextMenu (per-app)
  const resources = ctx.apis.resource.getRegisteredResources()
}

Vanilla JS / window.CyWebApi

window.addEventListener('cywebapi:ready', () => {
  const api = window.CyWebApi

  const result = api.workspace.getCurrentNetworkId()
  if (result.success) {
    console.log('current network:', result.data.networkId)
  }
})

Note: window.CyWebApi is typed as CyWebApiType which does NOT include resource or per-app contextMenu. These are only available via AppContextApis inside mount() or useAppContext().

Available cyweb/* remotes

| Remote | Hook | |--------|------| | cyweb/ElementApi | useElementApi() | | cyweb/NetworkApi | useNetworkApi() | | cyweb/SelectionApi | useSelectionApi() | | cyweb/ViewportApi | useViewportApi() | | cyweb/TableApi | useTableApi() | | cyweb/VisualStyleApi | useVisualStyleApi() | | cyweb/LayoutApi | useLayoutApi() | | cyweb/ExportApi | useExportApi() | | cyweb/WorkspaceApi | useWorkspaceApi() | | cyweb/EventBus | useCyWebEvent(type, handler) | | cyweb/AppIdContext | useAppContext() — per-app context for plugin components | | cyweb/ApiTypes | Re-exports all types from this package |

Documentation

License

MIT