Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@w6s/cordova-import

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@w6s/cordova-import

Automatic CordovaJs import util.

  • 1.3.2
  • latest
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

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',
  },
  ...
};

Keywords

FAQs

Package last updated on 13 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc