Skip to content

Commit

Permalink
feat: support bytedance microapp in universal-env (#61)
Browse files Browse the repository at this point in the history
* feat: support isByteDance (#60)

* feat: support isByteDance

* fix: beta version

* fix: isByteDanceMicroApp

* Fix: exclude tt in judgement of wechat mini program (#65)

* feat: support isByteDance

* fix: beta version

* fix: isByteDanceMicroApp

* feat: exclude tt in isWeChatMiniProgram

* feat: exclude tt in isWeChatMiniProgram

* fix: version

* chore: bump version

Co-authored-by: 小杰 <wlj136209@alibaba-inc.com>
  • Loading branch information
SoloJiang and wanglijie authored Apr 1, 2020
1 parent 2bb6ea5 commit 4eacc7c
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 56 deletions.
33 changes: 20 additions & 13 deletions packages/env/README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
判断和获取运行时环境

## 支持
<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="quickApp" src="https://gw.alicdn.com/tfs/TB1MP7EwQT2gK0jSZPcXXcKkpXa-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"> <img alt="bytedanceMicroApp" src="https://gw.alicdn.com/tfs/TB1jFtVzO_1gK0jSZFqXXcpaXXa-200-200.svg" width="25px" height="25px"> <img alt="quickApp" src="https://gw.alicdn.com/tfs/TB1MP7EwQT2gK0jSZPcXXcKkpXa-200-200.svg" width="25px" height="25px">

## 安装
```bash
Expand All @@ -12,7 +12,7 @@ $ npm install universal-env --save

## 示例
```javascript
import { isWeex, isWeb, isMiniApp, isNode, isWeChatMiniProgram, isQuickApp } from 'universal-env';
import { isWeex, isWeb, isMiniApp, isNode, isWeChatMiniProgram, isByteDanceMicroApp, isQuickApp } from 'universal-env';

```

Expand All @@ -29,6 +29,9 @@ import { isWeex, isWeb, isMiniApp, isNode, isWeChatMiniProgram, isQuickApp } fro
### `isWeChatMiniProgram: boolean`
校验微信小程序环境

### `isByteDanceMicroApp: boolean`
校验字节跳动小程序环境

### `isQuickApp: boolean`
校验快应用环境

Expand All @@ -37,17 +40,21 @@ import { isWeex, isWeb, isMiniApp, isNode, isWeChatMiniProgram, isQuickApp } fro

## 各容器内返回结果

| | isMiniApp | isWeChatMiniProgram | isQuickApp | isWeb | isWeex | isNode |
| ------------------ | --------- | ------------------- | ---------- | ----- | ------ | ------ |
| 阿里小程序 | ✔️ ||||||
| 阿里小程序 WebView | ✔️ ||| ✔️ |||
| 微信小程序 || ✔️ |||||
| 微信小程序 WebView || ✔️ || ✔️ |||
| 快应用 ||| ✔️ ||||
| 快应用 WebView |||| ✔️ |||
| Weex ||||| ✔️ ||
| Node |||||| ✔️ |
| Web |||| ✔️ |||
注:以下各小程序 WebView 内容器判断依赖 WebView 中注入容器的JS SDK。

| | isMiniApp | isWeChatMiniProgram | isByteDanceMicroApp | isQuickApp | isWeb | isWeex | isNode |
| ------------------- | --------- | ------------------- | ------------------ | ---------- | ----- | ------ | ------ |
| 阿里小程序 | ✔️ |||||||
| 阿里小程序 WebView | ✔️ |||| ✔️ |||
| 微信小程序 || ✔️ ||||||
| 微信小程序 WebView || ✔️ ||| ✔️ |||
| 字节跳动小程序 ||| ✔️ |||||
| 字节跳动小程序 WebView ||| ✔️ || ✔️ |||
| 快应用 |||| ✔️ ||||
| 快应用 WebView ||||| ✔️ |||
| Weex |||||| ✔️ ||
| Node ||||||| ✔️ |
| Web ||||| ✔️ |||



34 changes: 20 additions & 14 deletions packages/env/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
Judge runtime environment

## 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="wechatMiniprogram" src="https://img.alicdn.com/tfs/TB1slcYdxv1gK0jSZFFXXb0sXXa-200-200.svg" width="25px" height="25px"> <img alt="quickApp" src="https://gw.alicdn.com/tfs/TB1MP7EwQT2gK0jSZPcXXcKkpXa-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"> <img alt="bytedanceMicroApp" src="https://gw.alicdn.com/tfs/TB1jFtVzO_1gK0jSZFqXXcpaXXa-200-200.svg" width="25px" height="25px"> <img alt="quickApp" src="https://gw.alicdn.com/tfs/TB1MP7EwQT2gK0jSZPcXXcKkpXa-200-200.svg" width="25px" height="25px">

## Install
```bash
Expand All @@ -13,7 +12,7 @@ $ npm install universal-env --save

## Usage
```javascript
import { isWeex, isWeb, isMiniApp, isNode, isWeChatMiniProgram, isQuickApp } from 'universal-env';
import { isWeex, isWeb, isMiniApp, isNode, isWeChatMiniProgram, isByteDanceMicroApp, isQuickApp } from 'universal-env';

```

Expand All @@ -30,6 +29,9 @@ Checks if environment is an alibaba miniprogram environment.
### `isWeChatMiniProgram: boolean`
Checks if environment is a wechat miniprogram environment.

### `isByteDanceMicroApp: boolean`
Checks if environment is a bytedance microapp environment.

### `isQuickApp: boolean`
Checks if environment is a quickapp environment.

Expand All @@ -38,16 +40,20 @@ Checks if environment is a Node.js environment.

## Results in each container

| | isMiniApp | isWeChatMiniProgram | isQuickApp | isWeb | isWeex | isNode |
| ---------------------------- | --------- | ------------------- | ---------- | ----- | ------ | ------ |
| Alibaba MiniApp | ✔️ ||||||
| Alibaba MiniApp WebView | ✔️ ||| ✔️ |||
| Wechat MiniProgram || ✔️ |||||
| Wechat MiniProgram WebView || ✔️ || ✔️ |||
| QuickApp ||| ✔️ ||||
| QuickApp WebView |||| ✔️ |||
| Weex ||||| ✔️ ||
| Node |||||| ✔️ |
| Web |||| ✔️ |||
Note:To judge MiniProgram env in WebView, please insert JS SDK accordingly.

| | isMiniApp | isWeChatMiniProgram | isByteDanceMicroApp | isQuickApp | isWeb | isWeex | isNode |
| ----------------------------- | --------- | ------------------- | ------------------- | ---------- | ----- | ------ | ------ |
| Alibaba MiniApp | ✔️ |||||||
| Alibaba MiniApp WebView | ✔️ |||| ✔️ |||
| Wechat MiniProgram || ✔️ ||||||
| Wechat MiniProgram WebView || ✔️ ||| ✔️ |||
| ByteDance MicroApp ||| ✔️ |||||
| ByteDance MicroApp WebView ||| ✔️ || ✔️ |||
| QuickApp |||| ✔️ ||||
| QuickApp WebView ||||| ✔️ |||
| Weex |||||| ✔️ ||
| Node ||||||| ✔️ |
| Web ||||| ✔️ |||


33 changes: 20 additions & 13 deletions packages/env/docs-template/README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
判断和获取运行时环境

## 支持
__icon_web__ __icon_weex__ __icon_miniapp_mp__ __icon_miniapp_wx__ __icon_quick_app__
__icon_web__ __icon_weex__ __icon_miniapp_mp__ __icon_miniapp_wx__ __icon_microapp_tt__ __icon_quick_app__

## 安装
```bash
Expand All @@ -12,7 +12,7 @@ $ npm install universal-env --save

## 示例
```javascript
import { isWeex, isWeb, isMiniApp, isNode, isWeChatMiniProgram, isQuickApp } from 'universal-env';
import { isWeex, isWeb, isMiniApp, isNode, isWeChatMiniProgram, isByteDanceMicroApp, isQuickApp } from 'universal-env';

```

Expand All @@ -29,6 +29,9 @@ import { isWeex, isWeb, isMiniApp, isNode, isWeChatMiniProgram, isQuickApp } fro
### `isWeChatMiniProgram: boolean`
校验微信小程序环境

### `isByteDanceMicroApp: boolean`
校验字节跳动小程序环境

### `isQuickApp: boolean`
校验快应用环境

Expand All @@ -37,17 +40,21 @@ import { isWeex, isWeb, isMiniApp, isNode, isWeChatMiniProgram, isQuickApp } fro

## 各容器内返回结果

| | isMiniApp | isWeChatMiniProgram | isQuickApp | isWeb | isWeex | isNode |
| ------------------ | --------- | ------------------- | ---------- | ----- | ------ | ------ |
| 阿里小程序 | ✔️ ||||||
| 阿里小程序 WebView | ✔️ ||| ✔️ |||
| 微信小程序 || ✔️ |||||
| 微信小程序 WebView || ✔️ || ✔️ |||
| 快应用 ||| ✔️ ||||
| 快应用 WebView |||| ✔️ |||
| Weex ||||| ✔️ ||
| Node |||||| ✔️ |
| Web |||| ✔️ |||
注:以下各小程序 WebView 内容器判断依赖 WebView 中注入容器的JS SDK。

| | isMiniApp | isWeChatMiniProgram | isByteDanceMicroApp | isQuickApp | isWeb | isWeex | isNode |
| ------------------- | --------- | ------------------- | ------------------ | ---------- | ----- | ------ | ------ |
| 阿里小程序 | ✔️ |||||||
| 阿里小程序 WebView | ✔️ |||| ✔️ |||
| 微信小程序 || ✔️ ||||||
| 微信小程序 WebView || ✔️ ||| ✔️ |||
| 字节跳动小程序 ||| ✔️ |||||
| 字节跳动小程序 WebView ||| ✔️ || ✔️ |||
| 快应用 |||| ✔️ ||||
| 快应用 WebView ||||| ✔️ |||
| Weex |||||| ✔️ ||
| Node ||||||| ✔️ |
| Web ||||| ✔️ |||



33 changes: 20 additions & 13 deletions packages/env/docs-template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Judge runtime environment

## Support
__icon_web__ __icon_weex__ __icon_miniapp_mp__ __icon_miniapp_wx__ __icon_quick_app__
__icon_web__ __icon_weex__ __icon_miniapp_mp__ __icon_miniapp_wx__ __icon_microapp_tt__ __icon_quick_app__

## Install
```bash
Expand All @@ -12,7 +12,7 @@ $ npm install universal-env --save

## Usage
```javascript
import { isWeex, isWeb, isMiniApp, isNode, isWeChatMiniProgram, isQuickApp } from 'universal-env';
import { isWeex, isWeb, isMiniApp, isNode, isWeChatMiniProgram, isByteDanceMicroApp, isQuickApp } from 'universal-env';

```

Expand All @@ -29,6 +29,9 @@ Checks if environment is an alibaba miniprogram environment.
### `isWeChatMiniProgram: boolean`
Checks if environment is a wechat miniprogram environment.

### `isByteDanceMicroApp: boolean`
Checks if environment is a bytedance microapp environment.

### `isQuickApp: boolean`
Checks if environment is a quickapp environment.

Expand All @@ -37,16 +40,20 @@ Checks if environment is a Node.js environment.

## Results in each container

| | isMiniApp | isWeChatMiniProgram | isQuickApp | isWeb | isWeex | isNode |
| ---------------------------- | --------- | ------------------- | ---------- | ----- | ------ | ------ |
| Alibaba MiniApp | ✔️ ||||||
| Alibaba MiniApp WebView | ✔️ ||| ✔️ |||
| Wechat MiniProgram || ✔️ |||||
| Wechat MiniProgram WebView || ✔️ || ✔️ |||
| QuickApp ||| ✔️ ||||
| QuickApp WebView |||| ✔️ |||
| Weex ||||| ✔️ ||
| Node |||||| ✔️ |
| Web |||| ✔️ |||
Note:To judge MiniProgram env in WebView, please insert JS SDK accordingly.

| | isMiniApp | isWeChatMiniProgram | isByteDanceMicroApp | isQuickApp | isWeb | isWeex | isNode |
| ----------------------------- | --------- | ------------------- | ------------------- | ---------- | ----- | ------ | ------ |
| Alibaba MiniApp | ✔️ |||||||
| Alibaba MiniApp WebView | ✔️ |||| ✔️ |||
| Wechat MiniProgram || ✔️ ||||||
| Wechat MiniProgram WebView || ✔️ ||| ✔️ |||
| ByteDance MicroApp ||| ✔️ |||||
| ByteDance MicroApp WebView ||| ✔️ || ✔️ |||
| QuickApp |||| ✔️ ||||
| QuickApp WebView ||||| ✔️ |||
| Weex |||||| ✔️ ||
| Node ||||||| ✔️ |
| Web ||||| ✔️ |||


2 changes: 1 addition & 1 deletion packages/env/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "universal-env",
"author": "rax",
"version": "3.1.0",
"version": "3.2.0",
"description": "",
"main": "lib/index.js",
"files": [
Expand Down
Loading

0 comments on commit 4eacc7c

Please sign in to comment.