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

@w6s/cordova-import

v1.3.2

Published

Automatic CordovaJs import util.

Downloads

14

Readme

cordova-import Build Status npm version

cordova-import.js提供在 WorkPlus WebView 中注入 cordova 的能力,默认以local的方式注入,但同时会根据不同的环境,例如轻应用的访问协议(http、https),是否在 iframe 内打开等,自动选择最佳的注入方式,开发者无需关注过多的注入细节,开箱即用,一步到位!

如何使用

请确保脚本cordova-import.jsios.cordova.min.jsandroid.cordova.min.js放置到同一个资源目录,以确保脚本的正确加载。并且,为了提高资源的下载速度,请配置相关服务端的资源压缩策略,例如开启gzip

相关脚本可在Release页面进行下载。

一、通过 script 标签直接引入

单页面应用(SPA)引入一次即可,多页面应用还需在每个页面都单独引入

简单地在index.html头部引入即可:

<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <!-- 直接添加即可 -->
    <script src="//workplus.io/cordova-import.js" type="text/javascript"></script>
    
    <title>Cordova Import Demo</title>
  </head>
  <body>
    <div id="app"></div> 
  </body>
</html>

二、通过 npm 安装

yarn add @w6s/cordova-import
# or 
npm install @w6s/cordova-import -S

尽可能在应用入口引入并初始化,以确保尽可能早地注入 CordovaJs

import CordovaImport from '@w6s/cordova-import';

CordovaImport.init('//workplus.io/'); // URI 无需带上访问协议,必须以斜杠结尾

当前仅支持传入 js 加载地址(非必须),默认使用local模式,以加速开发效率!

若不传入地址,将完全使用local模式,请根据实际情况进行选择

配置说明

const config = {
  // 只有作为es模块初始化时,才需配置
  SDK_HOST: null,
  ...

  // 不同平台的 CordovaJs
  cordovajs: {
    iOS: 'ios.cordova.min.js',
    android: 'android.cordova.min.js',
    local: 'applocal://cordova.min.js',
  },
  ...
};