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

@swanide/extension

v0.0.6

Published

swanide extension api

Downloads

10

Readme

@swanide/extension

swanide 扩展 API,可以在 百度小程序开发工具 中进行扩展开发。

下载 百度小程序开发工具

使用方法

在开发者工具 extension 扩展中:

import {swanideInExtension as swanide} from '@swanide/extension';

export function activate() {
    swanide.ideReady(() => {
        swanide.executeCommand('swanide.simulator.refresh');
    });
}

注意: extension 扩展的加载顺序可能会在工具 ready 之前,需要调用 ideReady 事件才可以运行工具提供的函数。

在开发者工具 widget 扩展中:

import {ExtensionContext} from 'vscode';
import {swanideInWidget as swanide} from '@swanide/extension';

export function activate(context: ExtensionContext) {
    swanide.executeCommand('swanide.simulator.refresh');
}

在开发者工具 window 窗口中:

import {swanideInWindow as swanide} from '@swanide/extension';

swanide.executeCommand('swanide.simulator.refresh');

开发者工具扩展点

开发者工具对 vscode 扩展点做了增强,增加了以下几个扩展点:

  • widgets 扩展点
  • toolbars 扩展点

widgets 扩展点

开发者工具扩展支持在 renderer 视图注入 widget,每个 widget 为一个扩展模块,在 workbench 主视图加载后进行加载。 widget 模块 为工具提供操作主视图的能力,同时支持更多 swanide 相关API。

package.json 扩展点如下:

"contributes": {
    // widget 扩展点
    "widgets": [
        {
            // widget id 模块唯一标识,不可重复
            "id": "swanide-extension-example.widget",
            // widget 入口
            "entry": "./dist/widget.js",
            // 入口加载模式,默认为 amd,由于开发者工具更依赖 commonjs 模块,这里提供了 commonjs 加载模式
            "entryType": "commonjs"
        }
    ]
},

widget 入口模块:

/**
 * swanide widget 扩展
 */
import {swanide, WidgetContext} from '@swanide/extension';

export function activate(context: WidgetContext) {
    console.log('swanide extension path', context.extensionPath);
    swanide.executeCommand('swanide-extension-example.helloWorld');
}

toolbars 扩展点

开发者工具扩展支持工具栏按钮设置,点击按钮运行指定命令。

package.json 扩展点如下:

"contributes": {
    // toolbars 扩展点
    "toolbars": [
        {
            "name": "swanide-extension-example-btn",
            "text": "示例扩展按钮",
            "icon": "search",
            "command": "editor.action.formatDocument",
            "tooltip": "示例扩展按钮",
            "type": "button",
            // 分组:develop | deploy | debug | cloud | guide | info
            "group": "right",
            // 分组内排序
            "order": 100
        }
    ]
},