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

@tybys/jweixin

v1.6.10007

Published

Weixin JS SDK UMD with typescript typings

Downloads

1,525

Readme

jweixin

微信 JSSDK UMD 版本,并且附带 TypeScript 声明文件,提供 API 智能补全及类型提示。

官方提供的版本不能在 Webpack 里使用,改成 UMD 可以方便模块化开发。

版本号说明:

主版本号和次版本号跟随官方,修订号长度为 5 位,第一位固定是 1, 第二第三位是官方修订号,第四第五位是这个包的修订号,例如:

如果官方 sdk 版本是 1.6.0,这个包对应的版本是 1.6.100xx

如果官方 sdk 版本是 1.6.12,这个包对应的版本是 1.6.112xx

截图

tip1.png tip2.png tip3.png

安装

用 NPM:

$ npm install @tybys/jweixin

从仓库源码构建:

$ git clone https://github.com/toyobayashi/jweixin.git
$ cd jweixin
$ npm install
$ npm run build

输出在 dist 目录。

如果构建失败,请到文档中找他的地址下载一份 jweixin-x.x.x.js 手动放到 src/jweixin.min.js 后重新执行 npm run build

用法

在全局从 CDN 引入

<script src="https://cdn.jsdelivr.net/npm/@tybys/jweixin/dist/jweixin.min.js"></script>
<!-- 也可以直接引用官方的 -->
<!-- <script src="http://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script> -->
<script src="your-script.js"></script>
// your-script.js

// 三斜线指令引用声明文件,可在 VSCode 中看到智能提示
/// <reference path="node_modules/@tybys/jweixin/typings/jweixin.d.ts" />

console.log(wx);
console.log(jWeixin);

在纯 JS 项目中要获取 TS 类型智能提示,除了可以使用三斜线指令,也可以配置 jsconfig.json,类似 tsconfig.json,在 includefiles 数组中加入声明文件,VS Code 能认识 jsconfig.json

{
  "compilerOptions": {
    // ...
  },
  "include": [
    "path/to/your-script.js",
    "node_modules/@tybys/jweixin/typings/jweixin.d.ts",
    // ...
  ]
}

Webpack

CommonJS:

const wx = require('@tybys/jweixin')

ES Module:

// 下面两种都可以
import * as wx from '@tybys/jweixin'
import wx from '@tybys/jweixin'

TypeScript

全局引入 SDK,只需要配置 tsconfig.json

{
  "compilerOptions": {
    // ...
  },
  "include": [
    "node_modules/@tybys/jweixin/typings/jweixin.d.ts",
    // ...
  ]
}

CommonJS:

{
  "compilerOptions": {
    // ...
    "moduleResolution": "node",
    "module": "CommonJS",
    // "esModuleInterop": true
  }
}
// 当 module 为 CommonJS 时
import wx = require('@tybys/jweixin') // ok
import * as wx from '@tybys/jweixin' // ok
import wx from '@tybys/jweixin' // compilerOptions.esModuleInterop = true

ES Module:

{
  "compilerOptions": {
    // ...
    "moduleResolution": "node",
    "module": "ESNext",
    // "allowSyntheticDefaultImports": true
  }
}
// 当 module 为 ES 模块时,不能使用 import x = require()
import * as wx from '@tybys/jweixin' // ok
import wx from '@tybys/jweixin' // compilerOptions.allowSyntheticDefaultImports = true