@uni-helper/uni-env 0.1.8 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,40 +1,24 @@
1
- # @uni-helper/uni-env
1
+ <a href="https://uni-helper.js.org/uni-env"><img src="./banner.svg" alt="banner" width="100%"/></a>
2
2
 
3
- uni-app 中优雅地判断当前环境。
3
+ <br >
4
+ <a href="https://github.com/uni-helper/uni-env/stargazers"><img src="https://img.shields.io/github/stars/uni-helper/uni-env?colorA=005947&colorB=eee&style=for-the-badge"></a>
5
+ <a href="https://www.npmjs.com/package/@uni-helper/uni-env"><img src="https://img.shields.io/npm/dm/@uni-helper/uni-env?colorA=005947&colorB=eee&style=for-the-badge"></a>
6
+ <a href="https://www.npmjs.com/package/@uni-helper/uni-env"><img src="https://img.shields.io/npm/v/@uni-helper/uni-env?colorA=005947&colorB=eee&style=for-the-badge"></a>
7
+
8
+ [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/uni-helper/uni-env)
4
9
 
5
- [![npm version][npm-version-src]][npm-version-href]
6
- [![npm downloads][npm-downloads-src]][npm-downloads-href]
7
- [![bundle][bundle-src]][bundle-href]
8
- [![License][license-src]][license-href]
9
- [![JSDocs][jsdocs-src]][jsdocs-href]
10
+ uni-app 中优雅地判断当前环境。
10
11
 
11
12
  ## 安装
12
13
 
13
- ```sh
14
+ ```bash
14
15
  pnpm i @uni-helper/uni-env
15
16
  ```
16
17
 
17
18
  ## 使用
18
19
 
19
- ```js
20
- // ESM
21
- import { isMpWeixin } from '@uni-helper/uni-env'
20
+ 📖 **请阅读[完整文档](https://uni-helper.js.org/uni-env)了解完整使用方法!**
22
21
 
23
- // CommonJS
24
- const { isMp } = require('@uni-helper/uni-env')
22
+ ```ts
23
+ import { isMpWeixin } from '@uni-helper/uni-env'
25
24
  ```
26
-
27
- > [!NOTE]
28
- > 这个包更多的是为插件开发者提供,如果你在运行时引入并不能做到条件编译。
29
- > 要做条件编译的话,请使用官方的 [跨端兼容 - 条件编译](https://uniapp.dcloud.net.cn/tutorial/platform.html#preprocessor),如果你需要更好的条件编译,你可以使用 [unplugin-preprocessor-directives](https://github.com/KeJunMao/unplugin-preprocessor-directives)
30
-
31
- [npm-version-src]: https://img.shields.io/npm/v/@uni-helper/uni-env?style=flat&colorA=18181B&colorB=F0DB4F
32
- [npm-version-href]: https://npmjs.com/package/@uni-helper/uni-env
33
- [npm-downloads-src]: https://img.shields.io/npm/dm/@uni-helper/uni-env?style=flat&colorA=18181B&colorB=F0DB4F
34
- [npm-downloads-href]: https://npmjs.com/package/@uni-helper/uni-env
35
- [bundle-src]: https://img.shields.io/bundlephobia/minzip/@uni-helper/uni-env?style=flat&colorA=18181B&colorB=F0DB4F
36
- [bundle-href]: https://bundlephobia.com/result?p=@uni-helper/uni-env
37
- [license-src]: https://img.shields.io/github/license/uni-helper/uni-env.svg?style=flat&colorA=18181B&colorB=F0DB4F
38
- [license-href]: https://github.com/uni-helper/uni-env/blob/main/LICENSE
39
- [jsdocs-src]: https://img.shields.io/badge/jsDocs.io-reference-18181B?style=flat&colorA=18181B&colorB=F0DB4F
40
- [jsdocs-href]: https://www.jsdocs.io/package/@uni-helper/uni-env
package/dist/index.cjs CHANGED
@@ -1,103 +1,440 @@
1
- 'use strict';
2
-
3
- const stdEnv = require('std-env');
4
-
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let std_env = require("std-env");
3
+ //#region src/utils.ts
5
4
  function toBoolean(val) {
6
- return val ? val !== "false" : false;
5
+ return val ? val !== "false" : false;
7
6
  }
8
7
  function parseJSON(val) {
9
- let obj;
10
- try {
11
- obj = JSON.parse(val || "{}");
12
- } catch (error) {
13
- obj = {};
14
- }
15
- return obj;
8
+ let obj;
9
+ try {
10
+ obj = JSON.parse(val || "{}");
11
+ } catch {
12
+ obj = {};
13
+ }
14
+ return obj;
16
15
  }
17
-
18
- const builtInPlatforms = ["h5", "web", "app", "app-plus", "app-harmony", "mp-360", "mp-alipay", "mp-baidu", "mp-qq", "mp-toutiao", "mp-weixin", "mp-kuaishou", "mp-lark", "mp-jd", "mp-xhs", "quickapp-webview", "quickapp-webview-huawei", "quickapp-webview-union"];
16
+ //#endregion
17
+ //#region src/index.ts
18
+ const builtInPlatforms = [
19
+ "h5",
20
+ "web",
21
+ "app",
22
+ "app-plus",
23
+ "app-harmony",
24
+ "mp-360",
25
+ "mp-alipay",
26
+ "mp-baidu",
27
+ "mp-qq",
28
+ "mp-toutiao",
29
+ "mp-weixin",
30
+ "mp-kuaishou",
31
+ "mp-lark",
32
+ "mp-jd",
33
+ "mp-xhs",
34
+ "mp-harmony",
35
+ "quickapp-webview",
36
+ "quickapp-webview-huawei",
37
+ "quickapp-webview-union"
38
+ ];
39
+ /**
40
+ * `process.env.UNI_PLATFORM`
41
+ *
42
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L9}
43
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-uni-app.d.ts#L24}
44
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-uni-app.d.ts#L193-L211}
45
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/uni-cli-shared/src/env/define.ts#L24}
46
+ */
19
47
  const platform = process.env.UNI_PLATFORM;
20
- const appPlatform = stdEnv.env.UNI_APP_PLATFORM;
48
+ /**
49
+ * `process.env.UNI_APP_PLATFORM`
50
+ *
51
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L10}
52
+ */
53
+ const appPlatform = std_env.env.UNI_APP_PLATFORM;
54
+ /**
55
+ * `process.env.UNI_SUB_PLATFORM`
56
+ *
57
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L11}
58
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/uni-cli-shared/src/env/define.ts#L25-L27}
59
+ */
21
60
  const subPlatform = process.env.UNI_SUB_PLATFORM;
22
- const utsPlatform = stdEnv.env.UNI_UTS_PLATFORM;
61
+ /**
62
+ * `process.env.UNI_UTS_PLATFORM`
63
+ *
64
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L12}
65
+ */
66
+ const utsPlatform = std_env.env.UNI_UTS_PLATFORM;
67
+ /** Detect if `process.env.UNI_PLATFORM` is `h5` or if `process.env.UNI_PLATFORM` is `web` */
23
68
  const isH5 = platform === "h5" || platform === "web";
69
+ /** Get user agent string for browser detection */
70
+ const userAgent = typeof navigator !== "undefined" ? navigator.userAgent.toLowerCase() : "";
71
+ /** Detect if running in WeChat browser in H5 environment */
72
+ const isH5Weixin = isH5 && /micromessenger/i.test(userAgent);
73
+ /** Detect if running in Weibo client in H5 environment */
74
+ const isH5Weibo = isH5 && /weibo/i.test(userAgent);
75
+ /** Detect if running in Alipay client in H5 environment */
76
+ const isH5Alipay = isH5 && /alipayclient/i.test(userAgent);
77
+ /** Detect if `process.env.UNI_PLATFORM` is `web` or if `process.env.UNI_PLATFORM` is `h5` */
24
78
  const isWeb = platform === "web" || platform === "h5";
79
+ /** Detect if `process.env.UNI_PLATFORM` is `app` */
25
80
  const isApp = platform === "app";
81
+ /** Detect if `process.env.UNI_PLATFORM` is `app-plus` */
26
82
  const isAppPlus = platform === "app-plus";
83
+ /** Detect if `process.env.UNI_PLATFORM` is `app-harmony` */
27
84
  const isAppHarmony = platform === "app-harmony";
85
+ /** Detect if `process.env.UNI_APP_PLATFORM` is `android` or if `process.env.UNI_UTS_PLATFORM` is `app-android` */
28
86
  const isAppAndroid = appPlatform === "android" || utsPlatform === "app-android";
87
+ /** Detect if `process.env.UNI_APP_PLATFORM` is `ios` or if `process.env.UNI_UTS_PLATFORM` is `app-ios` */
29
88
  const isAppIOS = appPlatform === "ios" || utsPlatform === "app-ios";
89
+ /** Detect if `process.env.UNI_PLATFORM` is `mp-*` */
30
90
  const isMp = /^mp-/i.test(platform);
91
+ /** Detect if `process.env.UNI_PLATFORM` is `mp-weixin` */
31
92
  const isMpWeixin = platform === "mp-weixin";
93
+ /** Detect if `process.env.UNI_PLATFORM` is `mp-alipay` */
32
94
  const isMpAlipay = platform === "mp-alipay";
95
+ /** Detect if `process.env.UNI_PLATFORM` is `mp-baidu` */
33
96
  const isMpBaidu = platform === "mp-baidu";
97
+ /** Detect if `process.env.UNI_PLATFORM` is `mp-kuaishou` */
34
98
  const isMpKuaishou = platform === "mp-kuaishou";
99
+ /** Detect if `process.env.UNI_PLATFORM` is `mp-qq` */
35
100
  const isMpQQ = platform === "mp-qq";
101
+ /** Detect if `process.env.UNI_PLATFORM` is `mp-toutiao` */
36
102
  const isMpToutiao = platform === "mp-toutiao";
103
+ /** Detect if `process.env.UNI_PLATFORM` is `mp-jd` */
104
+ const isMpJD = platform === "mp-jd";
105
+ /** Detect if `process.env.UNI_PLATFORM` is `mp-xhs` */
106
+ const isMpXHS = platform === "mp-xhs";
107
+ /** Detect if `process.env.UNI_PLATFORM` is `mp-harmony` */
108
+ const isMpHarmony = platform === "mp-harmony";
109
+ /** Detect if `process.env.UNI_PLATFORM` is `mp-360` */
110
+ const isMp360 = platform === "mp-360";
111
+ /** Detect if `process.env.UNI_PLATFORM` is `mp-lark` */
112
+ const isMpLark = platform === "mp-lark";
113
+ /** Detect if `process.env.UNI_PLATFORM` is `quickapp-webview*` */
37
114
  const isQuickapp = /^quickapp-webview/i.test(platform);
115
+ /** Detect if `process.env.UNI_PLATFORM` is `quickapp-webview-union` */
38
116
  const isQuickappUnion = platform === "quickapp-webview-union";
117
+ /** Detect if `process.env.UNI_PLATFORM` is `quickapp-webview-huawei` */
39
118
  const isQuickappHuawei = platform === "quickapp-webview-huawei";
40
- const utsJsCodeFormat = stdEnv.env.UNI_UTS_JS_CODE_FORMAT;
41
- const utsModuleType = stdEnv.env.UNI_UTS_MODULE_TYPE;
42
- const utsModulePrefix = stdEnv.env.UNI_UTS_MODULE_PREFIX;
43
- const utsTargetLanguage = stdEnv.env.UNI_UTS_TARGET_LANGUAGE;
44
- const inputDir = stdEnv.env.UNI_INPUT_DIR;
45
- const outputDir = stdEnv.env.UNI_OUTPUT_DIR;
46
- const cliContext = stdEnv.env.UNI_CLI_CONTEXT;
119
+ /**
120
+ * `process.env.UNI_UTS_JS_CODE_FORMAT`
121
+ *
122
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L14}
123
+ */
124
+ const utsJsCodeFormat = std_env.env.UNI_UTS_JS_CODE_FORMAT;
125
+ /**
126
+ * `process.env.UNI_UTS_MODULE_TYPE`
127
+ *
128
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L15}
129
+ */
130
+ const utsModuleType = std_env.env.UNI_UTS_MODULE_TYPE;
131
+ /**
132
+ * `process.env.UNI_UTS_MODULE_PREFIX`
133
+ *
134
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L16}
135
+ */
136
+ const utsModulePrefix = std_env.env.UNI_UTS_MODULE_PREFIX;
137
+ /**
138
+ * `process.env.UNI_UTS_TARGET_LANGUAGE`
139
+ *
140
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L17}
141
+ */
142
+ const utsTargetLanguage = std_env.env.UNI_UTS_TARGET_LANGUAGE;
143
+ /**
144
+ * `process.env.UNI_INPUT_DIR`
145
+ *
146
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L19}
147
+ */
148
+ const inputDir = std_env.env.UNI_INPUT_DIR;
149
+ /**
150
+ * `process.env.UNI_OUTPUT_DIR`
151
+ *
152
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L20}
153
+ */
154
+ const outputDir = std_env.env.UNI_OUTPUT_DIR;
155
+ /**
156
+ * `process.env.UNI_CLI_CONTEXT`
157
+ *
158
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L21}
159
+ */
160
+ const cliContext = std_env.env.UNI_CLI_CONTEXT;
161
+ /**
162
+ * `process.env.UNI_SUBPACKAGE`
163
+ *
164
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L22}
165
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/uni-cli-shared/src/env/define.ts#L31-L33}
166
+ */
47
167
  const subpackage = process.env.UNI_SUBPACKAGE;
168
+ /**
169
+ * `process.env.UNI_MP_PLUGIN`
170
+ *
171
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L23}
172
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/uni-cli-shared/src/env/define.ts#L28-L30}
173
+ */
48
174
  const mpPlugin = process.env.UNI_MP_PLUGIN;
175
+ /** Detect if `process.env.UNI_MP_PLUGIN` is set */
49
176
  const isMpPlugin = toBoolean(process.env.UNI_MP_PLUGIN);
177
+ /**
178
+ * `process.env.UNI_COMPILER_VERSION`
179
+ *
180
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L24}
181
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/uni-cli-shared/src/env/define.ts#L34-L36}
182
+ */
50
183
  const compilerVersion = process.env.UNI_COMPILER_VERSION;
51
- const compilerVersionType = stdEnv.env.UNI_COMPILER_VERSION_TYPE;
52
- const hbuilderxPlugins = stdEnv.env.UNI_HBUILDERX_PLUGINS;
53
- const renderer = stdEnv.env.UNI_RENDERER;
54
- const nvueCompiler = stdEnv.env.UNI_NVUE_COMPILER;
55
- const nvueStyleCompiler = stdEnv.env.UNI_NVUE_STYLE_COMPILER;
56
- const appCodeSpliting = stdEnv.env.UNI_APP_CODE_SPLITING;
184
+ /**
185
+ * `process.env.UNI_COMPILER_VERSION_TYPE`
186
+ *
187
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L25}
188
+ */
189
+ const compilerVersionType = std_env.env.UNI_COMPILER_VERSION_TYPE;
190
+ /**
191
+ * `process.env.UNI_HBUILDERX_PLUGINS`
192
+ *
193
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L26}
194
+ */
195
+ const hbuilderxPlugins = std_env.env.UNI_HBUILDERX_PLUGINS;
196
+ /**
197
+ * `process.env.UNI_RENDERER`
198
+ *
199
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L27}
200
+ */
201
+ const renderer = std_env.env.UNI_RENDERER;
202
+ /**
203
+ * `process.env.UNI_NVUE_COMPILER`
204
+ *
205
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L28}
206
+ */
207
+ const nvueCompiler = std_env.env.UNI_NVUE_COMPILER;
208
+ /**
209
+ * `process.env.UNI_NVUE_STYLE_COMPILER`
210
+ *
211
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L29}
212
+ */
213
+ const nvueStyleCompiler = std_env.env.UNI_NVUE_STYLE_COMPILER;
214
+ /**
215
+ * `process.env.UNI_APP_CODE_SPLITING`
216
+ *
217
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L30}
218
+ */
219
+ const appCodeSpliting = std_env.env.UNI_APP_CODE_SPLITING;
220
+ /**
221
+ * `process.env.UNI_AUTOMATOR_WS_ENDPOINT`
222
+ *
223
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L31}
224
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/uni-cli-shared/src/env/define.ts#L40-L42}
225
+ */
57
226
  const automatorWsEndpoint = process.env.UNI_AUTOMATOR_WS_ENDPOINT;
58
- const automatorAppWebview = stdEnv.env.UNI_AUTOMATOR_APP_WEBVIEW;
227
+ /**
228
+ * `process.env.UNI_AUTOMATOR_APP_WEBVIEW`
229
+ *
230
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L32}
231
+ */
232
+ const automatorAppWebview = std_env.env.UNI_AUTOMATOR_APP_WEBVIEW;
233
+ /**
234
+ * `process.env.UNI_AUTOMATOR_APP_WEBVIEW_SRC`
235
+ *
236
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L33}
237
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/uni-cli-shared/src/env/define.ts#L43-L45}
238
+ */
59
239
  const automatorAppWebviewSrc = process.env.UNI_AUTOMATOR_APP_WEBVIEW_SRC;
60
- const h5Base = stdEnv.env.UNI_H5_BASE;
61
- const h5Browser = stdEnv.env.UNI_H5_BROWSER;
62
- const customScript = stdEnv.env.UNI_CUSTOM_SCRIPT;
63
- const customDefine = stdEnv.env.UNI_CUSTOM_DEFINE;
64
- const customContext = stdEnv.env.UNI_CUSTOM_CONTEXT;
65
- const minimize = stdEnv.env.UNI_MINIMIZE;
66
- const isMinimize = toBoolean(stdEnv.env.UNI_MINIMIZE);
67
- const uvue = stdEnv.env.UNI_UVUE;
68
- const isUVue = toBoolean(stdEnv.env.UNI_UVUE);
69
- const uvueTargetLanguage = stdEnv.env.UNI_UVUE_TARGET_LANGUAGE;
70
- const compiler = stdEnv.env.UNI_COMPILER;
71
- const rendererNative = stdEnv.env.UNI_RENDERER_NATIVE;
72
- const nvueAppStyles = stdEnv.env.UNI_NVUE_APP_STYLES;
73
- const appChangedFiles = stdEnv.env.UNI_APP_CHANGED_FILES;
74
- const appChangedPages = stdEnv.env.UNI_APP_CHANGED_PAGES;
240
+ /**
241
+ * `process.env.UNI_H5_BASE`
242
+ *
243
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L34}
244
+ */
245
+ const h5Base = std_env.env.UNI_H5_BASE;
246
+ /**
247
+ * `process.env.UNI_H5_BROWSER`
248
+ *
249
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L35}
250
+ */
251
+ const h5Browser = std_env.env.UNI_H5_BROWSER;
252
+ /**
253
+ * `process.env.UNI_CUSTOM_SCRIPT`
254
+ *
255
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L36}
256
+ */
257
+ const customScript = std_env.env.UNI_CUSTOM_SCRIPT;
258
+ /**
259
+ * `process.env.UNI_CUSTOM_DEFINE`
260
+ *
261
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L37}
262
+ */
263
+ const customDefine = std_env.env.UNI_CUSTOM_DEFINE;
264
+ /**
265
+ * `process.env.UNI_CUSTOM_CONTEXT`
266
+ *
267
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L38}
268
+ */
269
+ const customContext = std_env.env.UNI_CUSTOM_CONTEXT;
270
+ /**
271
+ * `process.env.UNI_MINIMIZE`
272
+ *
273
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L39}
274
+ */
275
+ const minimize = std_env.env.UNI_MINIMIZE;
276
+ /** Detect if `process.env.UNI_MINIMIZE` is set */
277
+ const isMinimize = toBoolean(std_env.env.UNI_MINIMIZE);
278
+ /**
279
+ * `process.env.UNI_UVUE`
280
+ *
281
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L40}
282
+ */
283
+ const uvue = std_env.env.UNI_UVUE;
284
+ /** Detect if `process.env.UNI_UVUE` is set */
285
+ const isUVue = toBoolean(std_env.env.UNI_UVUE);
286
+ /**
287
+ * `process.env.UNI_UVUE_TARGET_LANGUAGE`
288
+ *
289
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L41}
290
+ */
291
+ const uvueTargetLanguage = std_env.env.UNI_UVUE_TARGET_LANGUAGE;
292
+ /**
293
+ * `process.env.UNI_COMPILER`
294
+ *
295
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L42}
296
+ */
297
+ const compiler = std_env.env.UNI_COMPILER;
298
+ /**
299
+ * `process.env.UNI_RENDERER_NATIVE`
300
+ *
301
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L43}
302
+ */
303
+ const rendererNative = std_env.env.UNI_RENDERER_NATIVE;
304
+ /**
305
+ * `process.env.UNI_NVUE_APP_STYLES`
306
+ *
307
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L44}
308
+ */
309
+ const nvueAppStyles = std_env.env.UNI_NVUE_APP_STYLES;
310
+ /**
311
+ * `process.env.UNI_APP_CHANGED_FILES`
312
+ *
313
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L45}
314
+ */
315
+ const appChangedFiles = std_env.env.UNI_APP_CHANGED_FILES;
316
+ /**
317
+ * `process.env.UNI_APP_CHANGED_PAGES`
318
+ *
319
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L46}
320
+ */
321
+ const appChangedPages = std_env.env.UNI_APP_CHANGED_PAGES;
322
+ /**
323
+ * `process.env.VUE_APP_DARK_MODE`
324
+ *
325
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L47}
326
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/uni-cli-shared/src/env/define.ts#L56-L58}
327
+ */
75
328
  const darkMode = process.env.VUE_APP_DARK_MODE;
329
+ /** Detect if `process.env.VUE_APP_DARK_MODE` is set */
76
330
  const hasDarkMode = toBoolean(process.env.VUE_APP_DARK_MODE);
77
- const hxUseBaseType = stdEnv.env.HX_USE_BASE_TYPE;
78
- const hxDependenciesDir = stdEnv.env.HX_DEPENDENCIES_DIR;
79
- const appX = stdEnv.env.UNI_APP_X;
80
- const isAppX = toBoolean(stdEnv.env.UNI_APP_X);
81
- const appXCacheDir = stdEnv.env.UNI_APP_X_CACHE_DIR;
82
- const hxVersion = stdEnv.env.HX_VERSION;
83
- const appXPageCount = stdEnv.env.UNI_APP_X_PAGE_COUNT;
84
- const appXTsc = stdEnv.env.UNI_APP_X_TSC;
85
- const appXSingleThread = stdEnv.env.UNI_APP_X_SINGLE_THREAD;
86
- const appXSetup = stdEnv.env.UNI_APP_X_SETUP;
87
- const appXUVueScriptEngine = stdEnv.env.UNI_APP_X_UVUE_SCRIPT_ENGINE;
88
- const compileTarget = stdEnv.env.UNI_COMPILE_TARGET;
89
- const compileCloudDir = stdEnv.env.UNI_COMPILE_CLOUD_DIR;
90
- const modulesEncryptCacheDir = stdEnv.env.UNI_MODULES_ENCRYPT_CACHE_DIR;
91
- const appPackType = stdEnv.env.UNI_APP_PACK_TYPE;
92
- const appHarmonyProjectPath = stdEnv.env.UNI_APP_HARMONY_PROJECT_PATH;
93
- const statTitleJson = parseJSON(stdEnv.env.STAT_TITLE_JSON);
94
- const sourcemap = stdEnv.env.SOURCEMAP;
95
- const hasSourcemap = toBoolean(stdEnv.env.SOURCEMAP);
96
- const ssrClient = stdEnv.env.UNI_SSR_CLIENT;
97
- const isSSRClient = toBoolean(stdEnv.env.UNI_SSR_CLIENT);
98
- const ssrServer = stdEnv.env.UNI_SSR_SERVER;
99
- const isSSRServer = toBoolean(stdEnv.env.UNI_SSR_SERVER);
100
-
331
+ /**
332
+ * `process.env.HX_USE_BASE_TYPE`
333
+ *
334
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L48}
335
+ */
336
+ const hxUseBaseType = std_env.env.HX_USE_BASE_TYPE;
337
+ /**
338
+ * `process.env.HX_DEPENDENCIES_DIR`
339
+ *
340
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L49}
341
+ */
342
+ const hxDependenciesDir = std_env.env.HX_DEPENDENCIES_DIR;
343
+ /**
344
+ * `process.env.UNI_APP_X`
345
+ *
346
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L55}
347
+ */
348
+ const appX = std_env.env.UNI_APP_X;
349
+ /** Detect if `process.env.UNI_APP_X` is set */
350
+ const isAppX = toBoolean(std_env.env.UNI_APP_X);
351
+ /**
352
+ * `process.env.UNI_APP_X_CACHE_DIR`
353
+ *
354
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L56}
355
+ */
356
+ const appXCacheDir = std_env.env.UNI_APP_X_CACHE_DIR;
357
+ /**
358
+ * `process.env.HX_VERSION`
359
+ *
360
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L58}
361
+ */
362
+ const hxVersion = std_env.env.HX_VERSION;
363
+ /**
364
+ * `process.env.UNI_APP_X_PAGE_COUNT`
365
+ *
366
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L60}
367
+ */
368
+ const appXPageCount = std_env.env.UNI_APP_X_PAGE_COUNT;
369
+ /**
370
+ * `process.env.UNI_APP_X_TSC`
371
+ *
372
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L61}
373
+ */
374
+ const appXTsc = std_env.env.UNI_APP_X_TSC;
375
+ /**
376
+ * `process.env.UNI_APP_X_SINGLE_THREAD`
377
+ *
378
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L62}
379
+ */
380
+ const appXSingleThread = std_env.env.UNI_APP_X_SINGLE_THREAD;
381
+ /**
382
+ * `process.env.UNI_APP_X_SETUP`
383
+ *
384
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L63}
385
+ */
386
+ const appXSetup = std_env.env.UNI_APP_X_SETUP;
387
+ /**
388
+ * `process.env.UNI_APP_X_UVUE_SCRIPT_ENGINE`
389
+ *
390
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L64}
391
+ */
392
+ const appXUVueScriptEngine = std_env.env.UNI_APP_X_UVUE_SCRIPT_ENGINE;
393
+ /**
394
+ * `process.env.UNI_COMPILE_TARGET`
395
+ *
396
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L66}
397
+ */
398
+ const compileTarget = std_env.env.UNI_COMPILE_TARGET;
399
+ /**
400
+ * `process.env.UNI_COMPILE_CLOUD_DIR`
401
+ *
402
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L67}
403
+ */
404
+ const compileCloudDir = std_env.env.UNI_COMPILE_CLOUD_DIR;
405
+ /**
406
+ * `process.env.UNI_MODULES_ENCRYPT_CACHE_DIR`
407
+ *
408
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L68}
409
+ */
410
+ const modulesEncryptCacheDir = std_env.env.UNI_MODULES_ENCRYPT_CACHE_DIR;
411
+ /**
412
+ * `process.env.UNI_APP_PACK_TYPE`
413
+ *
414
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L70}
415
+ */
416
+ const appPackType = std_env.env.UNI_APP_PACK_TYPE;
417
+ /**
418
+ * `process.env.UNI_APP_HARMONY_PROJECT_PATH`
419
+ *
420
+ * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L72}
421
+ */
422
+ const appHarmonyProjectPath = std_env.env.UNI_APP_HARMONY_PROJECT_PATH;
423
+ /** `process.env.STAT_TITLE_JSON` */
424
+ const statTitleJson = parseJSON(std_env.env.STAT_TITLE_JSON);
425
+ /** `process.env.SOURCEMAP` */
426
+ const sourcemap = std_env.env.SOURCEMAP;
427
+ /** Detect if `process.env.SOURCEMAP` is set */
428
+ const hasSourcemap = toBoolean(std_env.env.SOURCEMAP);
429
+ /** `process.env.UNI_SSR_CLIENT` */
430
+ const ssrClient = std_env.env.UNI_SSR_CLIENT;
431
+ /** Detect if `process.env.UNI_SSR_CLIENT` is set */
432
+ const isSSRClient = toBoolean(std_env.env.UNI_SSR_CLIENT);
433
+ /** `process.env.UNI_SSR_SERVER` */
434
+ const ssrServer = std_env.env.UNI_SSR_SERVER;
435
+ /** Detect if `process.env.UNI_SSR_SERVER` is set */
436
+ const isSSRServer = toBoolean(std_env.env.UNI_SSR_SERVER);
437
+ //#endregion
101
438
  exports.appChangedFiles = appChangedFiles;
102
439
  exports.appChangedPages = appChangedPages;
103
440
  exports.appCodeSpliting = appCodeSpliting;
@@ -141,15 +478,23 @@ exports.isAppIOS = isAppIOS;
141
478
  exports.isAppPlus = isAppPlus;
142
479
  exports.isAppX = isAppX;
143
480
  exports.isH5 = isH5;
481
+ exports.isH5Alipay = isH5Alipay;
482
+ exports.isH5Weibo = isH5Weibo;
483
+ exports.isH5Weixin = isH5Weixin;
144
484
  exports.isMinimize = isMinimize;
145
485
  exports.isMp = isMp;
486
+ exports.isMp360 = isMp360;
146
487
  exports.isMpAlipay = isMpAlipay;
147
488
  exports.isMpBaidu = isMpBaidu;
489
+ exports.isMpHarmony = isMpHarmony;
490
+ exports.isMpJD = isMpJD;
148
491
  exports.isMpKuaishou = isMpKuaishou;
492
+ exports.isMpLark = isMpLark;
149
493
  exports.isMpPlugin = isMpPlugin;
150
494
  exports.isMpQQ = isMpQQ;
151
495
  exports.isMpToutiao = isMpToutiao;
152
496
  exports.isMpWeixin = isMpWeixin;
497
+ exports.isMpXHS = isMpXHS;
153
498
  exports.isQuickapp = isQuickapp;
154
499
  exports.isQuickappHuawei = isQuickappHuawei;
155
500
  exports.isQuickappUnion = isQuickappUnion;
package/dist/index.d.cts CHANGED
@@ -1,3 +1,4 @@
1
+ //#region src/index.d.ts
1
2
  type OptionalBooleanString = 'true' | 'false' | undefined;
2
3
  type OptionalString = string | undefined;
3
4
  /**
@@ -8,7 +9,7 @@ type OptionalString = string | undefined;
8
9
  * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-uni-app.d.ts#L193-L211}
9
10
  * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/uni-cli-shared/src/env/define.ts#L24}
10
11
  */
11
- type BuiltInPlatform = 'h5' | 'web' | 'app' | 'app-plus' | 'app-harmony' | 'mp-360' | 'mp-alipay' | 'mp-baidu' | 'mp-qq' | 'mp-toutiao' | 'mp-weixin' | 'mp-kuaishou' | 'mp-lark' | 'mp-jd' | 'mp-xhs' | 'quickapp-webview' | 'quickapp-webview-huawei' | 'quickapp-webview-union';
12
+ type BuiltInPlatform = 'h5' | 'web' | 'app' | 'app-plus' | 'app-harmony' | 'mp-360' | 'mp-alipay' | 'mp-baidu' | 'mp-qq' | 'mp-toutiao' | 'mp-weixin' | 'mp-kuaishou' | 'mp-lark' | 'mp-jd' | 'mp-xhs' | 'mp-harmony' | 'quickapp-webview' | 'quickapp-webview-huawei' | 'quickapp-webview-union';
12
13
  declare const builtInPlatforms: BuiltInPlatform[];
13
14
  /**
14
15
  * `process.env.UNI_PLATFORM`
@@ -59,6 +60,12 @@ type UtsPlatform = BuiltInPlatform | 'app-android' | 'app-ios' | 'web';
59
60
  declare const utsPlatform: UtsPlatform;
60
61
  /** Detect if `process.env.UNI_PLATFORM` is `h5` or if `process.env.UNI_PLATFORM` is `web` */
61
62
  declare const isH5: boolean;
63
+ /** Detect if running in WeChat browser in H5 environment */
64
+ declare const isH5Weixin: boolean;
65
+ /** Detect if running in Weibo client in H5 environment */
66
+ declare const isH5Weibo: boolean;
67
+ /** Detect if running in Alipay client in H5 environment */
68
+ declare const isH5Alipay: boolean;
62
69
  /** Detect if `process.env.UNI_PLATFORM` is `web` or if `process.env.UNI_PLATFORM` is `h5` */
63
70
  declare const isWeb: boolean;
64
71
  /** Detect if `process.env.UNI_PLATFORM` is `app` */
@@ -85,6 +92,16 @@ declare const isMpKuaishou: boolean;
85
92
  declare const isMpQQ: boolean;
86
93
  /** Detect if `process.env.UNI_PLATFORM` is `mp-toutiao` */
87
94
  declare const isMpToutiao: boolean;
95
+ /** Detect if `process.env.UNI_PLATFORM` is `mp-jd` */
96
+ declare const isMpJD: boolean;
97
+ /** Detect if `process.env.UNI_PLATFORM` is `mp-xhs` */
98
+ declare const isMpXHS: boolean;
99
+ /** Detect if `process.env.UNI_PLATFORM` is `mp-harmony` */
100
+ declare const isMpHarmony: boolean;
101
+ /** Detect if `process.env.UNI_PLATFORM` is `mp-360` */
102
+ declare const isMp360: boolean;
103
+ /** Detect if `process.env.UNI_PLATFORM` is `mp-lark` */
104
+ declare const isMpLark: boolean;
88
105
  /** Detect if `process.env.UNI_PLATFORM` is `quickapp-webview*` */
89
106
  declare const isQuickapp: boolean;
90
107
  /** Detect if `process.env.UNI_PLATFORM` is `quickapp-webview-union` */
@@ -499,5 +516,5 @@ declare const isSSRClient: boolean;
499
516
  declare const ssrServer: OptionalBooleanString;
500
517
  /** Detect if `process.env.UNI_SSR_SERVER` is set */
501
518
  declare const isSSRServer: boolean;
502
-
503
- export { type AppPackType, type AppPlatform, type AppXUVueScriptEngine, type BuiltInPlatform, type CompileTarget, type Compiler, type CompilerVersionType, type H5Browser, type HxUseBaseType, type NVueCompiler, type NVueStyleCompiler, type OptionalBooleanString, type OptionalString, type Renderer, type RendererNative, type SubPlatform, type UVueTargetLanguage, type UtsJsCodeFormat, type UtsModuleType, type UtsPlatform, type UtsTargetLanguage, appChangedFiles, appChangedPages, appCodeSpliting, appHarmonyProjectPath, appPackType, appPlatform, appX, appXCacheDir, appXPageCount, appXSetup, appXSingleThread, appXTsc, appXUVueScriptEngine, automatorAppWebview, automatorAppWebviewSrc, automatorWsEndpoint, builtInPlatforms, cliContext, compileCloudDir, compileTarget, compiler, compilerVersion, compilerVersionType, customContext, customDefine, customScript, darkMode, h5Base, h5Browser, hasDarkMode, hasSourcemap, hbuilderxPlugins, hxDependenciesDir, hxUseBaseType, hxVersion, inputDir, isApp, isAppAndroid, isAppHarmony, isAppIOS, isAppPlus, isAppX, isH5, isMinimize, isMp, isMpAlipay, isMpBaidu, isMpKuaishou, isMpPlugin, isMpQQ, isMpToutiao, isMpWeixin, isQuickapp, isQuickappHuawei, isQuickappUnion, isSSRClient, isSSRServer, isUVue, isWeb, minimize, modulesEncryptCacheDir, mpPlugin, nvueAppStyles, nvueCompiler, nvueStyleCompiler, outputDir, platform, renderer, rendererNative, sourcemap, ssrClient, ssrServer, statTitleJson, subPlatform, subpackage, utsJsCodeFormat, utsModulePrefix, utsModuleType, utsPlatform, utsTargetLanguage, uvue, uvueTargetLanguage };
519
+ //#endregion
520
+ export { AppPackType, AppPlatform, AppXUVueScriptEngine, BuiltInPlatform, CompileTarget, Compiler, CompilerVersionType, H5Browser, HxUseBaseType, NVueCompiler, NVueStyleCompiler, OptionalBooleanString, OptionalString, Renderer, RendererNative, SubPlatform, UVueTargetLanguage, UtsJsCodeFormat, UtsModuleType, UtsPlatform, UtsTargetLanguage, appChangedFiles, appChangedPages, appCodeSpliting, appHarmonyProjectPath, appPackType, appPlatform, appX, appXCacheDir, appXPageCount, appXSetup, appXSingleThread, appXTsc, appXUVueScriptEngine, automatorAppWebview, automatorAppWebviewSrc, automatorWsEndpoint, builtInPlatforms, cliContext, compileCloudDir, compileTarget, compiler, compilerVersion, compilerVersionType, customContext, customDefine, customScript, darkMode, h5Base, h5Browser, hasDarkMode, hasSourcemap, hbuilderxPlugins, hxDependenciesDir, hxUseBaseType, hxVersion, inputDir, isApp, isAppAndroid, isAppHarmony, isAppIOS, isAppPlus, isAppX, isH5, isH5Alipay, isH5Weibo, isH5Weixin, isMinimize, isMp, isMp360, isMpAlipay, isMpBaidu, isMpHarmony, isMpJD, isMpKuaishou, isMpLark, isMpPlugin, isMpQQ, isMpToutiao, isMpWeixin, isMpXHS, isQuickapp, isQuickappHuawei, isQuickappUnion, isSSRClient, isSSRServer, isUVue, isWeb, minimize, modulesEncryptCacheDir, mpPlugin, nvueAppStyles, nvueCompiler, nvueStyleCompiler, outputDir, platform, renderer, rendererNative, sourcemap, ssrClient, ssrServer, statTitleJson, subPlatform, subpackage, utsJsCodeFormat, utsModulePrefix, utsModuleType, utsPlatform, utsTargetLanguage, uvue, uvueTargetLanguage };