@uni-helper/uni-env 0.0.1 → 0.0.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
@@ -27,6 +27,12 @@ const { isMp } = require("@uni-helper/uni-env");
27
27
 
28
28
  你可以从 [./src/index.ts](./src/index.ts) 中查看更多标志以及如何判断的。
29
29
 
30
+ ## 注意
31
+
32
+ 这个包更多的是为插件开发者提供,如果你在运行时引入并不能做到条件编译。
33
+
34
+ 要做条件编译的话,请使用官方的 [跨端兼容 - 条件编译](https://uniapp.dcloud.net.cn/tutorial/platform.html#preprocessor),如果你需要更好的条件编译,你可以使用 [vite-plugin-conditional-compiler](https://github.com/KeJunMao/vite-plugin-conditional-compile)
35
+
30
36
  ## 协议
31
37
 
32
38
  [MIT](./LICENSE)
package/dist/index.cjs CHANGED
@@ -31,9 +31,18 @@ const isSSRClient = toBoolean(envShim.UNI_SSR_CLIENT);
31
31
  const isSSRServer = toBoolean(envShim.UNI_SSR_SERVER);
32
32
  const isH5 = platform === "h5";
33
33
  const isApp = platform === "app";
34
+ const isAppAndroid = appPlatform === "android" || utsPlatform === "app-android";
35
+ const isAppIOS = appPlatform === "ios" || utsPlatform === "app-ios";
34
36
  const isMp = /^mp-/i.test(platform);
35
37
  const isMpWeixin = platform === "mp-weixin";
36
38
  const isMpAlipay = platform === "mp-alipay";
39
+ const isMpBaidu = platform === "mp-baidu";
40
+ const isMpKuaishou = platform === "mp-kuaishou";
41
+ const isMpQQ = platform === "mp-qq";
42
+ const isMpToutiao = platform === "mp-toutiao";
43
+ const isQuickapp = /^quickapp--webview/i.test(platform);
44
+ const isQuickappUnion = platform === "quickapp-webview-union";
45
+ const isQuickappHuawei = platform === "quickapp-webview-huawei";
37
46
  function toBoolean(val) {
38
47
  return val ? val !== "false" : false;
39
48
  }
@@ -59,12 +68,21 @@ exports.hasDarkMode = hasDarkMode;
59
68
  exports.hasSourcemap = hasSourcemap;
60
69
  exports.inputDir = inputDir;
61
70
  exports.isApp = isApp;
71
+ exports.isAppAndroid = isAppAndroid;
72
+ exports.isAppIOS = isAppIOS;
62
73
  exports.isH5 = isH5;
63
74
  exports.isMinimize = isMinimize;
64
75
  exports.isMp = isMp;
65
76
  exports.isMpAlipay = isMpAlipay;
77
+ exports.isMpBaidu = isMpBaidu;
78
+ exports.isMpKuaishou = isMpKuaishou;
66
79
  exports.isMpPlugin = isMpPlugin;
80
+ exports.isMpQQ = isMpQQ;
81
+ exports.isMpToutiao = isMpToutiao;
67
82
  exports.isMpWeixin = isMpWeixin;
83
+ exports.isQuickapp = isQuickapp;
84
+ exports.isQuickappHuawei = isQuickappHuawei;
85
+ exports.isQuickappUnion = isQuickappUnion;
68
86
  exports.isSSRClient = isSSRClient;
69
87
  exports.isSSRServer = isSSRServer;
70
88
  exports.nvueCompiler = nvueCompiler;
package/dist/index.d.ts CHANGED
@@ -49,15 +49,33 @@ declare const isMinimize: boolean;
49
49
  declare const isSSRClient: boolean;
50
50
  /** Detect if `UNI_SSR_SERVER` environment variable is set */
51
51
  declare const isSSRServer: boolean;
52
- /** Detect if `process.env.UNI_PLATFORM` is H5 */
52
+ /** Detect if `process.env.UNI_PLATFORM` is `H5` */
53
53
  declare const isH5: boolean;
54
- /** Detect if `process.env.UNI_PLATFORM` is H5 */
54
+ /** Detect if `process.env.UNI_PLATFORM` is `APP` */
55
55
  declare const isApp: boolean;
56
- /** Detect if `process.env.UNI_PLATFORM` is 小程序 */
56
+ /** Detect if `process.env.UNI_APP_PLATFORM` is `android` or if `process.env.UNI_UTS_PLATFORM` is "app-android" */
57
+ declare const isAppAndroid: boolean;
58
+ /** Detect if `process.env.UNI_APP_PLATFORM` is `ios` or if `process.env.UNI_UTS_PLATFORM` is "app-ios"*/
59
+ declare const isAppIOS: boolean;
60
+ /** Detect if `process.env.UNI_PLATFORM` is `小程序` */
57
61
  declare const isMp: boolean;
58
- /** Detect if `process.env.UNI_PLATFORM` is 微信小程序 */
62
+ /** Detect if `process.env.UNI_PLATFORM` is `微信小程序` */
59
63
  declare const isMpWeixin: boolean;
60
- /** Detect if `process.env.UNI_PLATFORM` is 支付宝小程序 */
64
+ /** Detect if `process.env.UNI_PLATFORM` is `支付宝小程序` */
61
65
  declare const isMpAlipay: boolean;
66
+ /** Detect if `process.env.UNI_PLATFORM` is `百度小程序` */
67
+ declare const isMpBaidu: boolean;
68
+ /** Detect if `process.env.UNI_PLATFORM` is `快手小程序` */
69
+ declare const isMpKuaishou: boolean;
70
+ /** Detect if `process.env.UNI_PLATFORM` is `QQ小程序` */
71
+ declare const isMpQQ: boolean;
72
+ /** Detect if `process.env.UNI_PLATFORM` is `头条小程序` */
73
+ declare const isMpToutiao: boolean;
74
+ /** Detect if `process.env.UNI_PLATFORM` is `快应用` */
75
+ declare const isQuickapp: boolean;
76
+ /** Detect if `process.env.UNI_PLATFORM` is `快应用联盟` */
77
+ declare const isQuickappUnion: boolean;
78
+ /** Detect if `process.env.UNI_PLATFORM` is `快应用华为` */
79
+ declare const isQuickappHuawei: boolean;
62
80
 
63
- export { appPlatform, cliContext, compiler, compilerVersion, compilerVersionType, customContext, customDefine, customScript, hasDarkMode, hasSourcemap, inputDir, isApp, isH5, isMinimize, isMp, isMpAlipay, isMpPlugin, isMpWeixin, isSSRClient, isSSRServer, nvueCompiler, nvueStyleCompiler, outputDir, platform, renderer, rendererNative, statTitleJson, subPlatform, subpackage, utsPlatform };
81
+ export { appPlatform, cliContext, compiler, compilerVersion, compilerVersionType, customContext, customDefine, customScript, hasDarkMode, hasSourcemap, inputDir, isApp, isAppAndroid, isAppIOS, isH5, isMinimize, isMp, isMpAlipay, isMpBaidu, isMpKuaishou, isMpPlugin, isMpQQ, isMpToutiao, isMpWeixin, isQuickapp, isQuickappHuawei, isQuickappUnion, isSSRClient, isSSRServer, nvueCompiler, nvueStyleCompiler, outputDir, platform, renderer, rendererNative, statTitleJson, subPlatform, subpackage, utsPlatform };
package/dist/index.mjs CHANGED
@@ -29,9 +29,18 @@ const isSSRClient = toBoolean(envShim.UNI_SSR_CLIENT);
29
29
  const isSSRServer = toBoolean(envShim.UNI_SSR_SERVER);
30
30
  const isH5 = platform === "h5";
31
31
  const isApp = platform === "app";
32
+ const isAppAndroid = appPlatform === "android" || utsPlatform === "app-android";
33
+ const isAppIOS = appPlatform === "ios" || utsPlatform === "app-ios";
32
34
  const isMp = /^mp-/i.test(platform);
33
35
  const isMpWeixin = platform === "mp-weixin";
34
36
  const isMpAlipay = platform === "mp-alipay";
37
+ const isMpBaidu = platform === "mp-baidu";
38
+ const isMpKuaishou = platform === "mp-kuaishou";
39
+ const isMpQQ = platform === "mp-qq";
40
+ const isMpToutiao = platform === "mp-toutiao";
41
+ const isQuickapp = /^quickapp--webview/i.test(platform);
42
+ const isQuickappUnion = platform === "quickapp-webview-union";
43
+ const isQuickappHuawei = platform === "quickapp-webview-huawei";
35
44
  function toBoolean(val) {
36
45
  return val ? val !== "false" : false;
37
46
  }
@@ -45,4 +54,4 @@ function parseJSON(val) {
45
54
  return obj;
46
55
  }
47
56
 
48
- export { appPlatform, cliContext, compiler, compilerVersion, compilerVersionType, customContext, customDefine, customScript, hasDarkMode, hasSourcemap, inputDir, isApp, isH5, isMinimize, isMp, isMpAlipay, isMpPlugin, isMpWeixin, isSSRClient, isSSRServer, nvueCompiler, nvueStyleCompiler, outputDir, platform, renderer, rendererNative, statTitleJson, subPlatform, subpackage, utsPlatform };
57
+ export { appPlatform, cliContext, compiler, compilerVersion, compilerVersionType, customContext, customDefine, customScript, hasDarkMode, hasSourcemap, inputDir, isApp, isAppAndroid, isAppIOS, isH5, isMinimize, isMp, isMpAlipay, isMpBaidu, isMpKuaishou, isMpPlugin, isMpQQ, isMpToutiao, isMpWeixin, isQuickapp, isQuickappHuawei, isQuickappUnion, isSSRClient, isSSRServer, nvueCompiler, nvueStyleCompiler, outputDir, platform, renderer, rendererNative, statTitleJson, subPlatform, subpackage, utsPlatform };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uni-helper/uni-env",
3
3
  "type": "module",
4
- "version": "0.0.1",
4
+ "version": "0.0.2",
5
5
  "packageManager": "pnpm@8.1.1",
6
6
  "description": "",
7
7
  "author": "KeJun",