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

vscode-webview-tool

v1.0.4

Published

create webview html and regist RPC

Readme

vscode-webview-tool

方便vscode插件开发中使用webview的工具,方便将vue/react等框架生成的文件 作为vscode插件webview的html,并提供了双向注册RPC的方法,方便vscode插件与html互相调用

主要功能

  • 将普通html嵌入vscode插件webview
  • 提供双向注册RPC的方法
  • 为html本地调试提供mock vscodeAPI 和 mock RPC注册

安装

npm install vscode-webview-tool

使用

vscode插件

生成webview html

import { getHtmlForWebview } from 'vscode-webview-tool';

webview.html = getHtmlForWebview(context,'build/web','index.html');

context 为 vscode.ExtensionContext, 'build/web' 是web文件在项目下的路径, 'index.html' 为web的入口文件,多入口可以配置为其他入口文件名

对html的要求

不支持在js拆包懒加载。 可以在html中加载多个js,但是不能在js中动态加载本地js, 如lazyload

注册方法给html调用

// vscode
import { VscodeServiceProvider } from 'vscode-webview-tool'

webview.html = getHtmlForWebview(context,'build/web','index.html')

const serviceProvider = new VscodeServiceProvider(webview)
serviceProvider.provideService({
    common:{
        something: ()=>{
            // do something
        }
    }
})

//html 调用
import { WebServiceProvider } from 'vscode-webview-tool/lib/web'

const serviceProvider = new WebServiceProvider()
serviceProvider.callService('common','something')

html

调用vscode插件注册的方法

import { WebServiceProvider } from 'vscode-webview-tool/lib/web'

const serviceProvider = new WebServiceProvider()
serviceProvider.callService('common','something')

注册方法给vscode调用

与vscode插件中一致

// html
import { WebServiceProvider } from 'vscode-webview-tool/lib/web'

const serviceProvider = new WebServiceProvider()
serviceProvider.provideService({
    common:{
        something: ()=>{
            // do something
        }
    }
})

// vscode 调用
import { VscodeServiceProvider } from 'vscode-webview-tool'

const serviceProvider = new VscodeServiceProvider(webview)
serviceProvider.callService('common','something')

vscode api

获取了vscodeApi, 在非vscode环境也可以使用, 非vscode环境使用localStorage模拟State, 方便web调试

import { vscode } from 'vscode-webview-tool/lib/web'

vscode.postMessage('...')
vscode.getState()
vscode.setState({ a:1, b:2 })

示例项目

issue催催就有示例了...