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

@oasis-engine/miniprogram-adapter

v0.3.10

Published

adapter of miniprogram

Downloads

43

Readme

miniprogram-adapter

帮助互动框架适配到阿里系小程序。抹平 dom api 和小程序 api 的差异,目前适配对象:

  • 'window',
  • 'atob',
  • 'devicePixelRatio',
  • 'document',
  • 'Element',
  • 'Event',
  • 'EventTarget',
  • 'HTMLCanvasElement',
  • 'HTMLElement',
  • 'HTMLMediaElement',
  • 'HTMLVideoElement',
  • 'Image',
  • 'navigator',
  • 'Node',
  • 'requestAnimationFrame',
  • 'cancelAnimationFrame',
  • 'screen',
  • 'XMLHttpRequest',
  • 'performance',

适配用法

以 rollup 为例,使用 webpack 方案找到对应的方法即可:

  1. 安装 @rollup/plugin-inject 。

  2. 利用 @rollup/plugin-inject 在打包的过程中注入适配对象到代码中。

  3. (可选) 若使用的 monorepo 仓库,可使用 @rollup/plugin-modify 替换引用模块。l

下面是小程序 rollup.miniprogram.plugin.js 示例可以供参考:

import inject from 'rollup-plugin-inject';
import modify from 'rollup-plugin-modify';

const module = '@oasis-engine/miniprogram-adapter';

function register(name) {
  return [module, name];
}

const adapterArray = [
  'window',
  'atob',
  'devicePixelRatio',
  'document',
  'Element',
  'Event',
  'EventTarget',
  'HTMLCanvasElement',
  'HTMLElement',
  'HTMLMediaElement',
  'HTMLVideoElement',
  'Image',
  'navigator',
  'Node',
  'requestAnimationFrame',
  'cancelAnimationFrame',
  'screen',
  'XMLHttpRequest',
  'performance',
];
const adapterVars = {};

adapterArray.forEach(name => {
  adapterVars[name] = register(name);
});

export default [
  inject(adapterVars),
  modify({
    find: /@oasis-engine\/([\w-]*)/g,
    replace: (match, moduleName) => `@oasis-engine/${moduleName}/dist/miniprogram`
  }),
];