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/qrcodegen

v1.0.3

Published

WebAssembly version of [nayuki/QR-Code-generator](https://github.com/nayuki/QR-Code-generator).

Downloads

214

Readme

qrcodegen

WebAssembly version of nayuki/QR-Code-generator.

Build with wasi-sdk for small size instead of Emscripten.

Support browser and WeChat mini program.

API documentation

Usage

npm install @tybys/qrcodegen

HTML script tag

<!DOCTYPE html>
<html>
<head>
  <title>qrcodegen</title>
</head>
<body>
  <canvas width="200" height="200" id="canvas"></canvas>
  <script src="https://cdn.jsdelivr.net/npm/@tybys/qrcodegen/dist/qrcodegen.min.js"></script>
  <script>
  /// <reference path="./node_modules/@tybys/qrcodegen/dist/qrcodegen.d.ts" />

  qrcodegen.init().then(function (api) {
    var matrix = api.encodeText('Hello world!', qrcodegen.Ecc.LOW);

    /** @type {HTMLCanvasElement} */
    var canvas = document.getElementById('canvas');

    qrcodegen.drawCanvas(canvas, matrix, {
      // foregroundColor: '#000000',
      // backgroundColor: '#ffffff',
      // padding: 0
    });
  });
  </script>
</body>
</html>

Webpack

import { init, drawCanvas, Ecc } from '@tybys/qrcodegen'

init().then(function (api) {
  var matrix = api.encodeText('Hello world!', Ecc.LOW)

  /** @type {HTMLCanvasElement} */
  var canvas = document.getElementById('canvas')

  drawCanvas(canvas, matrix, {
    // foregroundColor: '#000000',
    // backgroundColor: '#ffffff',
    // padding: 0
  })
})

WeChat mini program

<canvas type="2d" id="canvas" style="width: 750rpx; height: 750rpx"></canvas>
const { init, drawCanvas, Ecc } = require('@tybys/qrcodegen')

const dpr = wx.getSystemInfoSync().pixelRatio
const scale = wx.getSystemInfoSync().screenWidth / 375

function getCanvas (id) {
  return new Promise(resolve => {
    const query = wx.createSelectorQuery()
    query.select(id)
      .fields({ node: true, size: true })
      .exec((res) => {
        resolve(res[0].node)
      })
  })
}

Page({
  onReady () {
    Promise.all([
      getCanvas('#canvas'),
      init()
    ]).then(([canvas, api]) => {
      canvas.width = 375 * scale * dpr
      canvas.height = 375 * scale * dpr

      const matrix = api.encodeText('Hello world!', Ecc.LOW)
      drawCanvas(canvas, matrix, {
        // foregroundColor: '#000000',
        // backgroundColor: '#ffffff',
        // padding: 0
      })
    })
  }
})

Building

Install wasi-sdk ($WASI_SDK_PATH) and binaryen

npm install --ignore-scripts
npm run build:wasm
npm run build