module-develop-kit 0.5.8 → 0.5.9

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.
@@ -9,6 +9,14 @@ import { PluginOption } from 'vite';
9
9
  */
10
10
  export declare const getCompatibilityPlugins: (options?: IVitePluginLegacyOptions) => PluginOption[];
11
11
 
12
+ export declare interface IVitePluginCompatibilityDetectionOptions extends HtmlTagDescriptor {
13
+ /**
14
+ * 检测平台
15
+ * @default pc
16
+ */
17
+ platform?: "pc" | "mobile";
18
+ }
19
+
12
20
  export declare interface IVitePluginLegacyOptions extends Options {
13
21
  /**
14
22
  * 是否开启
@@ -30,6 +38,6 @@ export declare interface IVitePluginLegacyOptions extends Options {
30
38
  * 兼容性检测
31
39
  * @param options 可以选择自定义插入内容
32
40
  */
33
- export declare const vitePluginCompatibilityDetection: (options?: HtmlTagDescriptor) => Plugin_2;
41
+ export declare const vitePluginCompatibilityDetection: (options?: IVitePluginCompatibilityDetectionOptions) => Plugin_2;
34
42
 
35
43
  export { }
@@ -1,30 +1,33 @@
1
- import a from "@vitejs/plugin-legacy";
2
- const s = `"use strict";!function(){var r=function(r){document.body?r():window.addEventListener("load",r,{once:!0})};function e(){r(function(){document.body.innerHTML='<div style="width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); position: fixed; left: 0; top: 0"><div style="width: 480px; background-color: #fff; margin: 200px auto; padding: 18px 22px 18px 16px; border-radius: 12px;"><div style="color: #4e5969; font-size: 14px; margin: 24px 0 26px 0">推荐使用谷歌浏览器访问系统,以获得更优操作体验,减少兼容问题</div><div style="display: flex; justify-content: flex-end"><a href="https://www.google.cn/chrome/" target="_blank" style="width: 146px;height: 32px;color: #fff;background-color: #2954ff;text-align: center;font-size: 14px;cursor: pointer;border-radius: 4px;text-decoration: none;display: flex;align-items: center;justify-content: center;">下载谷歌浏览器</a></div></div></div>',document.title="不支持该浏览器"})}try{!function(){var o=window.navigator.userAgent;function n(r){return r&&Array.isArray(r)&&r[1]?String(r[1]):null}function t(r){return n(r.match(/Chrom(?:e|ium)\\/(\\d+(\\.\\d+)*)/i))}function i(r,e){if(!e||!r)return!1;for(var o=String(r).split(".").map(Number),n=String(e).split(".").map(Number),t=0;t<Math.max(o.length,n.length);t++){var i=o[t]||0,c=n[t]||0;if(i>c)return!0;if(i<c)return!1}return!0}var c=85;function a(){r(function(){var r=document.getElementById("vite-legacy-polyfill");if(r){var e=document.createElement("script");e.src=r.src,document.head.appendChild(e)}else console.warn("没有找到vite-legacy-polyfill的加载入口")})}var s=[{name:"Ie",description:"detect IE engine (Trident/MSIE) — 360 在兼容模式下会走 Trident,IE不支持",match:function(r){return/MSIE |Trident\\//i.test(r)},notSupport:!0},{name:"360Browser",description:"360 安全/极速浏览器 (基于 Chromium)",match:function(r){return/(360SE|360EE)/i.test(r)},getBrowserVersion:t,minSupportVersion:c,forceLoadPolyfills:!0},{name:"Edge",description:"Edge (Chromium) token: Edg/",match:function(r){return Boolean(r.match(/Edg\\/(\\d+\\.?\\d*)/i))},getBrowserVersion:t,minSupportVersion:c,forceLoadPolyfills:!0},{name:"Firefox",match:function(r){return Boolean(r.match(/Firefox\\/(\\d+\\.?\\d*)/i))},getBrowserVersion:function(r){return n(r.match(/Firefox\\/(\\d+(\\.\\d+)*)/i))},minSupportVersion:90,forceLoadPolyfills:function(r){return i("104",n(r.match(/Firefox\\/(\\d+(\\.\\d+)*)/i)))}},{name:"Opera",description:"Opera 从 2013 年起转向 Chromium 内核,所以现在的 Opera 实际上是一个 Chromium 壳",match:function(r){return Boolean(r.match(/OPR\\/(\\d+\\.?\\d*)/i))},getBrowserVersion:t,minSupportVersion:c,forceLoadPolyfills:!0},{name:"QQBrowser",description:"QQ 浏览器(基于 Chromium),桌面和移动端",match:function(r){return Boolean(r.match(/QQBrowser\\/(\\d+\\.?\\d*)/i))},getBrowserVersion:t,minSupportVersion:c,forceLoadPolyfills:!0},{name:"UCBrowser",description:"UC 浏览器,主要在移动端",match:function(r){return Boolean(r.match(/UCBrowser\\/(\\d+\\.?\\d*)/i))},getBrowserVersion:t,minSupportVersion:c,forceLoadPolyfills:!0},{name:"WeChat",description:"微信内置浏览器(通常基于X5内核/Chromium),移动端",match:function(r){return Boolean(r.match(/MicroMessenger\\/(\\d+\\.?\\d*)/i))},getBrowserVersion:t,minSupportVersion:c,forceLoadPolyfills:!0},{name:"Chrome",description:"Chrome/Chromium (包含了很多套壳的chrome,Edge也包含了,但是在上面已经处理过了)",match:function(r){return Boolean(r.match(/Chrom(?:e|ium)\\/(\\d+)\\.?/i))},getBrowserVersion:t,minSupportVersion:c,forceLoadPolyfills:function(r){return i("107",t(r))}},{name:"Safari",description:'Safari: 包含 "Version/X Y Safari/" 没有 Chrome/Chromium/Edg/OPR',match:function(r){return!/Chrom(e|ium)|Edg|OPR|QQBrowser/i.test(r)},getBrowserVersion:function(r){return n(r.match(/Version\\/(\\d+(\\.\\d+)*)/i))},minSupportVersion:14.1,forceLoadPolyfills:function(r){return i("16",n(r.match(/Version\\/(\\d+(\\.\\d+)*)/i)))}}].find(function(r){return r.match(o)});if(s&&function(r){var e=r.match,n=r.getBrowserVersion,t=r.minSupportVersion,c=r.notSupport,a=r.name;if(!e(o))return!1;if(console.log("当前浏览器ua与",a,"匹配"),c)return!1;var s=n?n(o):null;return s?(console.log("当前浏览器:",a,s),i(s,t)):(console.log("获取不到当前浏览器版本:",a),!1)}(s))try{var u=null==s?void 0:s.forceLoadPolyfills;u&&("function"==typeof u?u(o)&&a():a())}catch(r){console.log("polyfills 强制加载失败",r)}else e()}()}catch(r){console.log("检测脚本执行失败",r),e()}}();`, u = (r) => ({
3
- name: "vite-plugin-compatibility-detection",
4
- enforce: "post",
5
- transformIndexHtml(e) {
6
- return {
7
- html: e,
8
- tags: [
9
- {
10
- tag: "script",
11
- children: s,
12
- // default head-prepend
13
- injectTo: "head-prepend",
14
- ...r || {}
15
- }
16
- ]
17
- };
18
- }
19
- }), d = (r) => {
20
- const e = {
1
+ import c from "@vitejs/plugin-legacy";
2
+ const a = `"use strict";!function(){function r(r){document.body?r():window.addEventListener("load",r,{once:!0})}function e(){r(function(){document.body.innerHTML='<div style="width:100%;height:100%;background-color:rgba(0,0,0,0.5);position:fixed;left:0;top:0"><div style="width:90%;max-width:480px;background-color:#fff;margin:150px auto;padding:20px;border-radius:8px;text-align:center;"><div style="color:#333;font-size:16px;margin-bottom:20px;">检测到您的浏览器版本较低或不受支持,建议使用主流浏览器访问页面以获得更好体验。</div><div><a href="https://play.google.com/store/apps/details?id=com.android.chrome" target="_blank" style="display:inline-block;padding:10px 16px;color:#fff;background-color:#4285F4;border-radius:4px;text-decoration:none;font-size:14px;">下载Chrome浏览器</a></div></div></div>',document.title="浏览器不受支持"})}try{!function(){var o=window.navigator.userAgent||"";function n(r){return r&&Array.isArray(r)&&r[1]?String(r[1]):null}function t(r){return n(r.match(/Chrom(?:e|ium)\\/(\\d+(\\.\\d+)*)/i))}function i(r,e){if(!r||!e)return!1;for(var o=String(r).split(".").map(Number),n=String(e).split(".").map(Number),t=0;t<Math.max(o.length,n.length);t++){var i=o[t]||0,s=n[t]||0;if(i>s)return!0;if(i<s)return!1}return!0}function s(){r(function(){var r=document.getElementById("vite-legacy-polyfill");if(r){var e=document.createElement("script");e.src=r.src,document.head.appendChild(e)}else console.warn("没有找到vite-legacy-polyfill的加载入口")})}var d=[{name:"WeChat",description:"微信/微信内置浏览器",match:function(r){return/MicroMessenger|WeiXin/i.test(r)},getBrowserVersion:function(){return"100"},minSupportVersion:1,forceLoadPolyfills:!0},{name:"Safari (iOS)",description:"iPhone/iPad Safari",match:function(r){return/Version\\/(\\d+(\\.\\d+)*)/.test(r)&&/Safari\\//.test(r)&&!/YaBrowser/.test(r)},getBrowserVersion:function(r){return n(r.match(/Version\\/(\\d+(\\.\\d+)*)/i))},minSupportVersion:12.1,forceLoadPolyfills:function(r){return i("16",n(r.match(/Version\\/(\\d+(\\.\\d+)*)/i)))}},{name:"Chrome (iOS)",description:"iOS 上的 Chrome (CriOS)",match:function(r){return/CriOS\\/(\\d+(\\.\\d+)*)/.test(r)},getBrowserVersion:function(r){return n(r.match(/CriOS\\/(\\d+(\\.\\d+)*)/i))},minSupportVersion:85,forceLoadPolyfills:!0},{name:"Firefox (iOS)",description:"iOS 上的 Firefox (FxiOS)",match:function(r){return/FxiOS\\/(\\d+(\\.\\d+)*)/.test(r)},getBrowserVersion:function(r){return n(r.match(/FxiOS\\/(\\d+(\\.\\d+)*)/i))},minSupportVersion:90,forceLoadPolyfills:!0},{name:"Yandex (iOS)",match:function(r){return/YaBrowser\\/(\\d+(\\.\\d+)*)/.test(r)},getBrowserVersion:function(r){return n(r.match(/YaBrowser\\/(\\d+(\\.\\d+)*)/i))},minSupportVersion:21,forceLoadPolyfills:!0},{name:"Chrome (Android)",description:"Android 上的 Chrome 浏览器",match:function(r){return/Chrome\\/(\\d+(\\.\\d+)*)/.test(r)&&!/EdgA/i.test(r)},getBrowserVersion:t,minSupportVersion:85,forceLoadPolyfills:function(r){return i("107",t(r))}},{name:"Firefox (Android)",match:function(r){return/Firefox\\/(\\d+(\\.\\d+)*)/.test(r)},getBrowserVersion:function(r){return n(r.match(/Firefox\\/(\\d+(\\.\\d+)*)/i))},minSupportVersion:90,forceLoadPolyfills:function(r){return i("104",n(r.match(/Firefox\\/(\\d+(\\.\\d+)*)/i)))}},{name:"Samsung Browser",match:function(r){return/SamsungBrowser\\/(\\d+(\\.\\d+)*)/.test(r)},getBrowserVersion:function(r){return n(r.match(/SamsungBrowser\\/(\\d+(\\.\\d+)*)/i))},minSupportVersion:18,forceLoadPolyfills:!1},{name:"Edge (Android)",match:function(r){return/EdgA\\/(\\d+(\\.\\d+)*)/.test(r)},getBrowserVersion:function(r){return n(r.match(/EdgA\\/(\\d+(\\.\\d+)*)/i))},minSupportVersion:85,forceLoadPolyfills:!0},{name:"Opera",match:function(r){return/OPR\\/(\\d+(\\.\\d+)*)/.test(r)},getBrowserVersion:t,minSupportVersion:85,forceLoadPolyfills:!0},{name:"Opera Mini",description:"Opera Mini(旧版浏览器,不支持)",match:function(r){return/Opera Mini/i.test(r)},notSupport:!0},{name:"UC Browser",match:function(r){return/UCBrowser\\/(\\d+(\\.\\d+)*)/.test(r)},getBrowserVersion:function(r){return n(r.match(/UCBrowser\\/(\\d+(\\.\\d+)*)/i))},minSupportVersion:12,forceLoadPolyfills:!0},{name:"QQ Browser",match:function(r){return/MQQBrowser\\/(\\d+(\\.\\d+)*)/.test(r)||/QQBrowser\\/(\\d+(\\.\\d+)*)/.test(r)},getBrowserVersion:function(r){var e=r.match(/(?:MQQBrowser|QQBrowser)\\/(\\d+(\\.\\d+)*)/i);return e?String(e[1]):null},minSupportVersion:10,forceLoadPolyfills:!0},{name:"Baidu Browser",match:function(r){return/baidubrowser\\/(\\d+(\\.\\d+)*)/i.test(r)},getBrowserVersion:function(r){return n(r.match(/baidubrowser\\/(\\d+(\\.\\d+)*)/i))},minSupportVersion:7,forceLoadPolyfills:!0},{name:"MIUI Browser",match:function(r){return/MiuiBrowser\\/(\\d+(\\.\\d+)*)/.test(r)},getBrowserVersion:function(r){return n(r.match(/MiuiBrowser\\/(\\d+(\\.\\d+)*)/i))},minSupportVersion:12,forceLoadPolyfills:!0},{name:"Huawei Browser",match:function(r){return/HuaweiBrowser\\/(\\d+(\\.\\d+)*)/.test(r)},getBrowserVersion:function(r){return n(r.match(/HuaweiBrowser\\/(\\d+(\\.\\d+)*)/i))},minSupportVersion:10,forceLoadPolyfills:!0},{name:"Vivo Browser",match:function(r){return/VivoBrowser\\/(\\d+(\\.\\d+)*)/.test(r)},getBrowserVersion:function(r){return n(r.match(/VivoBrowser\\/(\\d+(\\.\\d+)*)/i))},minSupportVersion:10,forceLoadPolyfills:!0},{name:"Android WebView",match:function(r){return/Version\\/(\\d+(\\.\\d+)*)/.test(r)&&/Mobile Safari\\//.test(r)},getBrowserVersion:function(r){return n(r.match(/Version\\/(\\d+(\\.\\d+)*)/i))},minSupportVersion:4,forceLoadPolyfills:!1}].find(function(r){return r.match(o)});if(d&&function(r){if(!r.match(o))return!1;if(console.log("匹配浏览器策略:",r.name),r.notSupport)return!1;var e=null;return r.getBrowserVersion&&(e=r.getBrowserVersion(o)),e?(alert("检测浏览器版本:".concat(r.name," ").concat(e)),i(e,r.minSupportVersion)):(console.log("无法获取版本号:",r.name),!1)}(d))try{var a=null==d?void 0:d.forceLoadPolyfills;a&&("function"==typeof a?a(o)&&s():s())}catch(r){console.log("Polyfill 加载失败:",r)}else e()}()}catch(r){console.log("检测脚本执行异常:",r),e()}}();`, d = `"use strict";!function(){function r(r){document.body?r():window.addEventListener("load",r,{once:!0})}function e(){r(function(){document.body.innerHTML='<div style="width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); position: fixed; left: 0; top: 0"><div style="width: 480px; background-color: #fff; margin: 200px auto; padding: 18px 22px 18px 16px; border-radius: 12px;"><div style="color: #4e5969; font-size: 14px; margin: 24px 0 26px 0">推荐使用谷歌浏览器访问系统,以获得更优操作体验,减少兼容问题</div><div style="display: flex; justify-content: flex-end"><a href="https://www.google.cn/chrome/" target="_blank" style="width: 146px;height: 32px;color: #fff;background-color: #2954ff;text-align: center;font-size: 14px;cursor: pointer;border-radius: 4px;text-decoration: none;display: flex;align-items: center;justify-content: center;">下载谷歌浏览器</a></div></div></div>',document.title="不支持该浏览器"})}try{!function(){var o=window.navigator.userAgent;function n(r){return r&&Array.isArray(r)&&r[1]?String(r[1]):null}function t(r){return n(r.match(/Chrom(?:e|ium)\\/(\\d+(\\.\\d+)*)/i))}function i(r,e){if(!r||!e)return!1;for(var o=String(r).split(".").map(Number),n=String(e).split(".").map(Number),t=0;t<Math.max(o.length,n.length);t++){var i=o[t]||0,c=n[t]||0;if(i>c)return!0;if(i<c)return!1}return!0}var c=85;function a(){r(function(){var r=document.getElementById("vite-legacy-polyfill");if(r){var e=document.createElement("script");e.src=r.src,document.head.appendChild(e)}else console.warn("没有找到vite-legacy-polyfill的加载入口")})}var s=[{name:"Ie",description:"detect IE engine (Trident/MSIE) — 360 在兼容模式下会走 Trident,IE不支持",match:function(r){return/MSIE |Trident\\//i.test(r)},notSupport:!0},{name:"360Browser",description:"360 安全/极速浏览器 (基于 Chromium)",match:function(r){return/(360SE|360EE)/i.test(r)},getBrowserVersion:t,minSupportVersion:c,forceLoadPolyfills:!0},{name:"Edge",description:"Edge (Chromium) token: Edg/",match:function(r){return Boolean(r.match(/Edg\\/(\\d+\\.?\\d*)/i))},getBrowserVersion:t,minSupportVersion:c,forceLoadPolyfills:!0},{name:"Firefox",match:function(r){return Boolean(r.match(/Firefox\\/(\\d+\\.?\\d*)/i))},getBrowserVersion:function(r){return n(r.match(/Firefox\\/(\\d+(\\.\\d+)*)/i))},minSupportVersion:90,forceLoadPolyfills:function(r){return i("104",n(r.match(/Firefox\\/(\\d+(\\.\\d+)*)/i)))}},{name:"Opera",description:"Opera 从 2013 年起转向 Chromium 内核,所以现在的 Opera 实际上是一个 Chromium 壳",match:function(r){return Boolean(r.match(/OPR\\/(\\d+\\.?\\d*)/i))},getBrowserVersion:t,minSupportVersion:c,forceLoadPolyfills:!0},{name:"QQBrowser",description:"QQ 浏览器(基于 Chromium),桌面和移动端",match:function(r){return Boolean(r.match(/QQBrowser\\/(\\d+\\.?\\d*)/i))},getBrowserVersion:t,minSupportVersion:c,forceLoadPolyfills:!0},{name:"UCBrowser",description:"UC 浏览器,主要在移动端",match:function(r){return Boolean(r.match(/UCBrowser\\/(\\d+\\.?\\d*)/i))},getBrowserVersion:t,minSupportVersion:c,forceLoadPolyfills:!0},{name:"WeChat",description:"微信内置浏览器(通常基于X5内核/Chromium),移动端",match:function(r){return Boolean(r.match(/MicroMessenger\\/(\\d+\\.?\\d*)/i))},getBrowserVersion:t,minSupportVersion:c,forceLoadPolyfills:!0},{name:"Chrome",description:"Chrome/Chromium (包含了很多套壳的chrome,Edge也包含了,但是在上面已经处理过了)",match:function(r){return Boolean(r.match(/Chrom(?:e|ium)\\/(\\d+)\\.?/i))},getBrowserVersion:t,minSupportVersion:c,forceLoadPolyfills:function(r){return i("107",t(r))}},{name:"Safari",description:'Safari: 包含 "Version/X Y Safari/" 没有 Chrome/Chromium/Edg/OPR',match:function(r){return!/Chrom(e|ium)|Edg|OPR|QQBrowser/i.test(r)},getBrowserVersion:function(r){return n(r.match(/Version\\/(\\d+(\\.\\d+)*)/i))},minSupportVersion:14.1,forceLoadPolyfills:function(r){return i("16",n(r.match(/Version\\/(\\d+(\\.\\d+)*)/i)))}}].find(function(r){return r.match(o)});if(s&&function(r){var e=r.match,n=r.getBrowserVersion,t=r.minSupportVersion,c=r.notSupport,a=r.name;if(!e(o))return!1;if(console.log("当前浏览器ua与",a,"匹配"),c)return!1;var s=n?n(o):null;return s?(console.log("当前浏览器:",a,s),i(s,t)):(console.log("获取不到当前浏览器版本:",a),!1)}(s))try{var u=null==s?void 0:s.forceLoadPolyfills;u&&("function"==typeof u?u(o)&&a():a())}catch(r){console.log("polyfills 强制加载失败",r)}else e()}()}catch(r){console.log("检测脚本执行失败",r),e()}}();`, u = (e) => {
3
+ const { platform: o, ...r } = e || { type: "pc" };
4
+ return {
5
+ name: "vite-plugin-compatibility-detection",
6
+ enforce: "post",
7
+ transformIndexHtml(n) {
8
+ return {
9
+ html: n,
10
+ tags: [
11
+ {
12
+ tag: "script",
13
+ children: o === "pc" ? d : a,
14
+ // default head-prepend
15
+ injectTo: "head-prepend",
16
+ ...r || {}
17
+ }
18
+ ]
19
+ };
20
+ }
21
+ };
22
+ }, f = (e) => {
23
+ const o = {
21
24
  start: !0,
22
25
  startDetection: !0,
23
- ...r || {}
24
- }, t = [], { start: o, startDetection: n, detectionConfig: i, ...c } = e;
25
- return o && (t.push(a(c)), n && t.push(u(i))), t;
26
+ ...e || {}
27
+ }, r = [], { start: n, startDetection: t, detectionConfig: i, ...s } = o;
28
+ return n && (r.push(c(s)), t && r.push(u(i))), r;
26
29
  };
27
30
  export {
28
- d as getCompatibilityPlugins,
31
+ f as getCompatibilityPlugins,
29
32
  u as vitePluginCompatibilityDetection
30
33
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "module-develop-kit",
3
3
  "author": "Front-End team",
4
- "version": "0.5.8",
4
+ "version": "0.5.9",
5
5
  "type": "module",
6
6
  "description": "前端项目通用工具包",
7
7
  "module": "dist/index.es.js",