universal-env
Advanced tools
Comparing version 2.0.0 to 3.0.0
@@ -1,1 +0,1 @@ | ||
"use strict";function isUndef(e){return"undefined"===e}Object.defineProperty(exports,"__esModule",{value:!0});var isWeb=!isUndef(typeof window)&&"onload"in window,isNode=!isUndef(typeof process)&&!(!process.versions||!process.versions.node),isWeex=!isUndef(typeof callNative)||!isUndef(typeof WXEnvironment)&&"Web"!==WXEnvironment.platform,isMiniApp=!isUndef(typeof my)&&!isUndef(my.navigateTo),isWeChatMiniprogram=!isUndef(typeof wx)&&!isUndef(wx.navigateTo);exports.isMiniApp=isMiniApp,exports.isNode=isNode,exports.isWeChatMiniprogram=isWeChatMiniprogram,exports.isWeb=isWeb,exports.isWeex=isWeex; | ||
"use strict";function isUndef(e){return"undefined"===e}Object.defineProperty(exports,"__esModule",{value:!0});var isWeb=!isUndef(typeof window)&&"onload"in window,isNode=!isUndef(typeof process)&&!(!process.versions||!process.versions.node),isWeex=!isUndef(typeof callNative)||!isUndef(typeof WXEnvironment)&&"Web"!==WXEnvironment.platform,isKraken=!isUndef(typeof __kraken__),isMiniApp=!isUndef(typeof my)&&null!==my&&!isUndef(my.alert),isWeChatMiniProgram=!(isUndef(typeof wx)||null===wx||isUndef(wx.login)&&isUndef(wx.miniProgram));exports.isKraken=isKraken,exports.isMiniApp=isMiniApp,exports.isNode=isNode,exports.isWeChatMiniProgram=isWeChatMiniProgram,exports.isWeb=isWeb,exports.isWeex=isWeex; |
export declare const isWeb: boolean; | ||
export declare const isNode: boolean; | ||
export declare const isWeex: boolean; | ||
export declare const isKraken: boolean; | ||
export declare const isMiniApp: boolean; | ||
export declare const isWeChatMiniprogram: boolean; | ||
export declare const isWeChatMiniProgram: boolean; |
@@ -12,9 +12,13 @@ 'use strict'; | ||
!isUndef(typeof WXEnvironment) && WXEnvironment.platform !== 'Web'; | ||
var isMiniApp = !isUndef(typeof my) && !isUndef(my.navigateTo); | ||
var isWeChatMiniprogram = !isUndef(typeof wx) && !isUndef(wx.navigateTo); | ||
var isKraken = !isUndef(typeof __kraken__); | ||
var isMiniApp = !isUndef(typeof my) && my !== null && !isUndef(my.alert); | ||
// In wechat mini program, wx.login is a function | ||
// In wechat mini propgram webview, there is no wx.login, but exist wx.miniProgram | ||
var isWeChatMiniProgram = !isUndef(typeof wx) && wx !== null && (!isUndef(wx.login) || !isUndef(wx.miniProgram)); | ||
exports.isKraken = isKraken; | ||
exports.isMiniApp = isMiniApp; | ||
exports.isNode = isNode; | ||
exports.isWeChatMiniprogram = isWeChatMiniprogram; | ||
exports.isWeChatMiniProgram = isWeChatMiniProgram; | ||
exports.isWeb = isWeb; | ||
exports.isWeex = isWeex; |
{ | ||
"name": "universal-env", | ||
"author": "rax", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"license": "BSD-3-Clause", | ||
@@ -11,5 +11,4 @@ "main": "index.js", | ||
"build": "rax-scripts build", | ||
"test": "rax-scripts test", | ||
"lint": "eslint --ext .js --ext .jsx --ext .ts --ext .tsx ./src", | ||
"prebuild": "npm run lint && npm run test", | ||
"prebuild": "npm run lint", | ||
"prepublish": "npm run build" | ||
@@ -43,8 +42,8 @@ }, | ||
"type": "git", | ||
"url": "https://github.com/raxjs/universal-env" | ||
"url": "https://github.com/raxjs/universal-api.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/raxjs/universal-env/issues" | ||
"url": "https://github.com/raxjs/universal-api/issues" | ||
}, | ||
"homepage": "https://github.com/raxjs/universal-env" | ||
"homepage": "https://github.com/raxjs/universal-api#readme" | ||
} |
@@ -6,3 +6,3 @@ # universal-env [![npm](https://img.shields.io/npm/v/universal-env.svg)](https://www.npmjs.com/package/universal-env) | ||
## 支持 | ||
<img alt="browser" src="https://gw.alicdn.com/tfs/TB1uYFobGSs3KVjSZPiXXcsiVXa-200-200.svg" width="25px" height="25px"> <img alt="weex" src="https://gw.alicdn.com/tfs/TB1jM0ebMaH3KVjSZFjXXcFWpXa-200-200.svg" width="25px" height="25px"> <img alt="miniApp" src="https://gw.alicdn.com/tfs/TB1bBpmbRCw3KVjSZFuXXcAOpXa-200-200.svg" width="25px" height="25px"> <img alt="wechatMiniprogram" src="https://img.alicdn.com/tfs/TB1slcYdxv1gK0jSZFFXXb0sXXa-200-200.svg" width="25px" height="25px"> | ||
<img alt="browser" src="https://gw.alicdn.com/tfs/TB1uYFobGSs3KVjSZPiXXcsiVXa-200-200.svg" width="25px" height="25px" /> <img alt="weex" src="https://gw.alicdn.com/tfs/TB1jM0ebMaH3KVjSZFjXXcFWpXa-200-200.svg" width="25px" height="25px" /> <img alt="miniApp" src="https://gw.alicdn.com/tfs/TB1bBpmbRCw3KVjSZFuXXcAOpXa-200-200.svg" width="25px" height="25px" /> <img alt="wechatMiniprogram" src="https://img.alicdn.com/tfs/TB1slcYdxv1gK0jSZFFXXb0sXXa-200-200.svg" width="25px" height="25px"> | ||
@@ -16,3 +16,3 @@ ## 安装 | ||
```javascript | ||
import { isWeex, isWeb, isMiniApp, isNode, isWeChatMiniprogram } from 'universal-env'; | ||
import { isWeex, isWeb, isMiniApp, isNode, isWeChatMiniProgram } from 'universal-env'; | ||
@@ -31,3 +31,3 @@ ``` | ||
### `isWeChatMiniprogram: boolean` | ||
### `isWeChatMiniProgram: boolean` | ||
校验微信小程序环境 | ||
@@ -40,3 +40,3 @@ | ||
| | isMiniApp | isWeChatMiniprogram | isWeb | isWeex | isNode | | ||
| | isMiniApp | isWeChatMiniProgram | isWeb | isWeex | isNode | | ||
| ------------------ | --------- | ------------------- | ----- | ------ | ------ | | ||
@@ -43,0 +43,0 @@ | 阿里小程序 | ✔️ | ✘ | ✘ | ✘ | ✘ | |
@@ -6,3 +6,3 @@ # universal-env [![npm](https://img.shields.io/npm/v/universal-env.svg)](https://www.npmjs.com/package/universal-env) | ||
## Support | ||
<img alt="browser" src="https://gw.alicdn.com/tfs/TB1uYFobGSs3KVjSZPiXXcsiVXa-200-200.svg" width="25px" height="25px" /> <img alt="weex" src="https://gw.alicdn.com/tfs/TB1jM0ebMaH3KVjSZFjXXcFWpXa-200-200.svg" width="25px" height="25px" /> <img alt="miniApp" src="https://gw.alicdn.com/tfs/TB1bBpmbRCw3KVjSZFuXXcAOpXa-200-200.svg" width="25px" height="25px" /> | ||
<img alt="browser" src="https://gw.alicdn.com/tfs/TB1uYFobGSs3KVjSZPiXXcsiVXa-200-200.svg" width="25px" height="25px" /> <img alt="weex" src="https://gw.alicdn.com/tfs/TB1jM0ebMaH3KVjSZFjXXcFWpXa-200-200.svg" width="25px" height="25px" /> <img alt="miniApp" src="https://gw.alicdn.com/tfs/TB1bBpmbRCw3KVjSZFuXXcAOpXa-200-200.svg" width="25px" height="25px" /> <img alt="wechatMiniprogram" src="https://img.alicdn.com/tfs/TB1slcYdxv1gK0jSZFFXXb0sXXa-200-200.svg" width="25px" height="25px"> | ||
@@ -16,3 +16,3 @@ ## Install | ||
```javascript | ||
import { isWeex, isWeb, isMiniApp, isNode, isWeChatMiniprogram } from 'universal-env'; | ||
import { isWeex, isWeb, isMiniApp, isNode, isWeChatMiniProgram } from 'universal-env'; | ||
@@ -31,3 +31,3 @@ ``` | ||
### `isWeChatMiniprogram: boolean` | ||
### `isWeChatMiniProgram: boolean` | ||
Checks if environment is a wechat miniprogram environment. | ||
@@ -40,8 +40,8 @@ | ||
| | isMiniApp | isWeChatMiniprogram | isWeb | isWeex | isNode | | ||
| | isMiniApp | isWeChatMiniProgram | isWeb | isWeex | isNode | | ||
| ------------------ | --------- | ------------------- | ----- | ------ | ------ | | ||
| Alibaba MiniApp | ✔️ | ✘ | ✘ | ✘ | ✘ | | ||
| Alibaba MiniApp WebView | ✔️ | ✘ | ✔️ | ✘ | ✘ | | ||
| Wechat Miniprogram | ✘ | ✔️ | ✘ | ✘ | ✘ | | ||
| Wechat Miniprogram WebView | ✘ | ✔️ | ✔️ | ✘ | ✘ | | ||
| Wechat MiniProgram | ✘ | ✔️ | ✘ | ✘ | ✘ | | ||
| Wechat MiniProgram WebView | ✘ | ✔️ | ✔️ | ✘ | ✘ | | ||
| Weex | ✘ | ✘ | ✘ | ✔️ | ✘ | | ||
@@ -48,0 +48,0 @@ | Node | ✘ | ✘ | ✘ | ✘ | ✔️ | |
declare const callNative: any; | ||
declare const WXEnvironment: any; | ||
declare const __kraken__: any; | ||
declare const my: any; | ||
@@ -16,4 +17,6 @@ declare const wx: any; | ||
!isUndef(typeof WXEnvironment) && WXEnvironment.platform !== 'Web'; | ||
export const isMiniApp = !isUndef(typeof my) && !isUndef(my.navigateTo); | ||
export const isWeChatMiniprogram = | ||
!isUndef(typeof wx) && !isUndef(wx.navigateTo); | ||
export const isKraken = !isUndef(typeof __kraken__); | ||
export const isMiniApp = !isUndef(typeof my) && my !== null && !isUndef(my.alert); | ||
// In wechat mini program, wx.login is a function | ||
// In wechat mini propgram webview, there is no wx.login, but exist wx.miniProgram | ||
export const isWeChatMiniProgram = !isUndef(typeof wx) && wx !== null && (!isUndef(wx.login) || !isUndef(wx.miniProgram)); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
15294
0
0
18