diff --git a/packages/env/README-zh_CN.md b/packages/env/README-zh_CN.md
index 03f168a9..b9ed4f81 100644
--- a/packages/env/README-zh_CN.md
+++ b/packages/env/README-zh_CN.md
@@ -3,7 +3,7 @@
判断和获取运行时环境
## 支持
-
+
## 安装
```bash
@@ -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';
```
@@ -29,6 +29,9 @@ import { isWeex, isWeb, isMiniApp, isNode, isWeChatMiniProgram, isQuickApp } fro
### `isWeChatMiniProgram: boolean`
校验微信小程序环境
+### `isByteDanceMicroApp: boolean`
+校验字节跳动小程序环境
+
### `isQuickApp: boolean`
校验快应用环境
@@ -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 | ✘ | ✘ | ✘ | ✘ | ✔️ | ✘ | ✘ |
diff --git a/packages/env/README.md b/packages/env/README.md
index 78cd28a5..75b3303c 100644
--- a/packages/env/README.md
+++ b/packages/env/README.md
@@ -3,8 +3,7 @@
Judge runtime environment
## Support
-
-
+
## Install
```bash
@@ -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';
```
@@ -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.
@@ -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 | ✘ | ✘ | ✘ | ✘ | ✔️ | ✘ | ✘ |
diff --git a/packages/env/docs-template/README-zh_CN.md b/packages/env/docs-template/README-zh_CN.md
index 60358ffe..7957d48c 100644
--- a/packages/env/docs-template/README-zh_CN.md
+++ b/packages/env/docs-template/README-zh_CN.md
@@ -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
@@ -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';
```
@@ -29,6 +29,9 @@ import { isWeex, isWeb, isMiniApp, isNode, isWeChatMiniProgram, isQuickApp } fro
### `isWeChatMiniProgram: boolean`
校验微信小程序环境
+### `isByteDanceMicroApp: boolean`
+校验字节跳动小程序环境
+
### `isQuickApp: boolean`
校验快应用环境
@@ -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 | ✘ | ✘ | ✘ | ✘ | ✔️ | ✘ | ✘ |
diff --git a/packages/env/docs-template/README.md b/packages/env/docs-template/README.md
index 81a82239..2e2871e3 100644
--- a/packages/env/docs-template/README.md
+++ b/packages/env/docs-template/README.md
@@ -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
@@ -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';
```
@@ -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.
@@ -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 | ✘ | ✘ | ✘ | ✘ | ✔️ | ✘ | ✘ |
diff --git a/packages/env/package.json b/packages/env/package.json
index 756792cf..3fb35ec2 100644
--- a/packages/env/package.json
+++ b/packages/env/package.json
@@ -1,7 +1,7 @@
{
"name": "universal-env",
"author": "rax",
- "version": "3.1.0",
+ "version": "3.2.0",
"description": "",
"main": "lib/index.js",
"files": [
diff --git a/packages/env/src/index.ts b/packages/env/src/index.ts
index 788e3ec8..cecd7b34 100644
--- a/packages/env/src/index.ts
+++ b/packages/env/src/index.ts
@@ -2,6 +2,7 @@ declare const WXEnvironment: any;
declare const __kraken__: any;
declare const my: any;
declare const wx: any;
+declare const tt: any;
declare const global: any;
function isUndef(type): boolean {
@@ -13,7 +14,9 @@ export const isNode = !isUndef(typeof process) && !!(process.versions && process
export const isWeex = !isUndef(typeof WXEnvironment) && WXEnvironment.platform !== 'Web';
export const isKraken = !isUndef(typeof __kraken__);
export const isMiniApp = !isUndef(typeof my) && my !== null && !isUndef(typeof my.alert);
+export const isByteDanceMicroApp = !isUndef(typeof tt) && tt !== null && !isUndef(typeof tt) && !isUndef(tt.showToast);
// 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(typeof wx.login) || !isUndef(typeof wx.miniProgram));
+// In bytedance maicro app, there is wx variable.
+export const isWeChatMiniProgram = !isByteDanceMicroApp && !isUndef(typeof wx) && wx !== null && (!isUndef(typeof wx.login) || !isUndef(typeof wx.miniProgram));
export const isQuickApp = !isUndef(typeof global) && global !== null && !isUndef(typeof global.callNative) && !isWeex;
diff --git a/scripts/compile-readme.js b/scripts/compile-readme.js
index cb438123..16d5c6a2 100644
--- a/scripts/compile-readme.js
+++ b/scripts/compile-readme.js
@@ -25,12 +25,13 @@ function buildPackage(packagesDir, packageDir) {
try {
mdFileNames = fs.readdirSync(path.resolve(packageDir, DOCS_TEMP_DIR));
} catch (e) {};
- const iconArr = ['__icon_web__', '__icon_weex__', '__icon_miniapp_mp__', '__icon_miniapp_wx__', '__icon_quick_app__'];
+ const iconArr = ['__icon_web__', '__icon_weex__', '__icon_miniapp_mp__', '__icon_miniapp_wx__', '__icon_microapp_tt__', '__icon_quick_app__'];
const iconMap = {
__icon_web__: '',
__icon_weex__: '',
__icon_miniapp_mp__: '',
__icon_miniapp_wx__: '',
+ __icon_microapp_tt__: '',
__icon_quick_app__: ''
};
mdFileNames.forEach(mdFileName => {