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

utools-api-types

v5.2.0

Published

TypeScript definitions for uTools API

Downloads

171

Readme

uTools 官方类型辅助文件

提供代码提示文件

window.utools 对象类型提示

目前将 utools 挂载到全局 window 下,提供在渲染层跟 preload 层的群体代码提示

第一步

npm install utools-api-types --save-dev

第二步 配置 tsconfig.json

{
  "compilerOptions": {
    "types": ["utools-api-types"]
  },
  "includes": [
    // 如果使用ts或者框架,请添加需要类型提示的文件范围
    // 案例:
    // src/**/*.ts
    // preload.js
  ]
}

API 代码示例

// 默认浏览器打开网页
window.utools.shellOpenExternal("https://u.tools");

// 在资源管理器中显示文件
window.utools.shellShowItemInFolder("d:\\test");

// ubrowser 网页自动化
window.utools.ubrowser
  .goto("https://cn.bing.com")
  .value("#sb_form_q", "uTools")
  .click("#sb_form_go")
  .run({ width: 1000, height: 600 });

// 值键对方式存储数据
window.utools.dbStorage.setItem("key", "value");

// 执行截图
window.utools.screenCapture((imagebase64) => {
  // 截图完的回调
});

// 执行取色
window.utools.screenColorPick(({ hex, rgb }) => {
  // 取色完的回调
});

electron 模块代码提示

引入此类型文件后,支持在 cjs 模式下也提供定制化的 electron 模块 api 提示

在 uTools 中,可以通过 cjs 的形式直接使用部分 electron 的 api ,但是此部分支持是直接通过 uTools 内置的 nodejs 实现,因此请勿下载额外的 electron 依赖。

API 代码示例

// preload.js

const { ipcRenderer } = require("electron");

window.onMyChannel = (callback) => {
  ipcRenderer.on("myChannel", (e, data) => {
    callback?.({
      ...data,
      senderId: e.senderId,
    });
  });
};

window.ipc = ipcRenderer;

配置文件 JSON Schema

通过 JSON Schema 实现了在 plugin.json 内的代码提示

引入 JSON Schema 需要在 plugin.json 的第一行添加 $schema 字段:

{
  "$schema": "./node_modules/utools-api-types/resource/utools.schema.json"
}

添加 $schema 时,需要注意跟 plugin.json 所在的文件位置有关系,必须是相对于 plugin.json 的位置