module-develop-kit 0.5.4 → 0.5.6
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/dist/index.es.js +15568 -15567
- package/dist/main.d.ts +40 -0
- package/dist/vite-plugins/index.es.js +4 -4
- package/package.json +2 -2
package/dist/main.d.ts
CHANGED
|
@@ -83,6 +83,46 @@ export declare const EMIT_EVENT_NAME: {
|
|
|
83
83
|
UPDATE_STATUS: string;
|
|
84
84
|
};
|
|
85
85
|
|
|
86
|
+
export declare class EventBus implements EventBusProps {
|
|
87
|
+
private _eventList;
|
|
88
|
+
private _toString;
|
|
89
|
+
/**
|
|
90
|
+
* 监听
|
|
91
|
+
* @param {string} eventName 需要监听的名字
|
|
92
|
+
* @param {Function} callback 监听触发的回调
|
|
93
|
+
* @param immediate 是否立即执行
|
|
94
|
+
* */
|
|
95
|
+
$on(eventName: string, callback: EventFnc, immediate?: boolean): void;
|
|
96
|
+
/**
|
|
97
|
+
* 分发事件
|
|
98
|
+
* @param {string} eventName 需要分发的监听的名字
|
|
99
|
+
* @param { any } args 传递的参数
|
|
100
|
+
* */
|
|
101
|
+
$emit(eventName: string, ...args: any): Promise<void | void[]>;
|
|
102
|
+
/**
|
|
103
|
+
* 取消监听
|
|
104
|
+
* @param {string | Array<string>} eventName 需要取消的监听名称
|
|
105
|
+
* */
|
|
106
|
+
$off(eventName?: string | string[]): void;
|
|
107
|
+
/**
|
|
108
|
+
* 执行一次的监听之后立即销毁
|
|
109
|
+
* @param {string} eventName 需要监听的名字
|
|
110
|
+
* @param {Function} callback 监听触发的回调
|
|
111
|
+
* */
|
|
112
|
+
$once(eventName: string, callback: EventFnc): void;
|
|
113
|
+
private _findEvent;
|
|
114
|
+
private _addEvent;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export declare interface EventBusProps {
|
|
118
|
+
$on(eventName: string, callback: EventFnc, immediate: boolean): void;
|
|
119
|
+
$emit(eventName: string, ...args: any): void;
|
|
120
|
+
$off(eventName?: string | string[]): void;
|
|
121
|
+
$once(eventName: string, callback: EventFnc): void;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
declare type EventFnc = (...args: any) => void;
|
|
125
|
+
|
|
86
126
|
/**
|
|
87
127
|
* 生成指定长度的随机字符串。
|
|
88
128
|
* 该函数通过从包含大小写字母和数字的字符集合中随机选取字符,拼接成所需长度的字符串。
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import a from "@vitejs/plugin-legacy";
|
|
2
|
-
const s = `"use strict";!function(){function r(){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="不支持该浏览器"}
|
|
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:79,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)))}}];if(s.some(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)}))try{var u=s.find(function(r){return r.match(o)}),d=null==u?void 0:u.forceLoadPolyfills;d&&("function"==typeof d?d(o)&&a():a())}catch(r){console.log("polyfills 强制加载失败",r)}else e()}()}catch(r){console.log("检测脚本执行失败",r),e()}}();`, u = (r) => ({
|
|
3
3
|
name: "vite-plugin-compatibility-detection",
|
|
4
4
|
enforce: "post",
|
|
5
5
|
transformIndexHtml(e) {
|
|
@@ -21,10 +21,10 @@ const s = `"use strict";!function(){function r(){document.body.innerHTML='<div s
|
|
|
21
21
|
start: !0,
|
|
22
22
|
startDetection: !0,
|
|
23
23
|
...r || {}
|
|
24
|
-
},
|
|
25
|
-
return
|
|
24
|
+
}, t = [], { start: o, startDetection: n, detectionConfig: i, ...c } = e;
|
|
25
|
+
return o && (t.push(a(c)), n && t.push(u(i))), t;
|
|
26
26
|
};
|
|
27
27
|
export {
|
|
28
28
|
l as getCompatibilityPlugins,
|
|
29
|
-
|
|
29
|
+
u as vitePluginCompatibilityDetection
|
|
30
30
|
};
|
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.
|
|
4
|
+
"version": "0.5.6",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "前端项目通用工具包",
|
|
7
7
|
"module": "dist/index.es.js",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|
|
17
17
|
"import": "./dist/index.es.js",
|
|
18
|
-
"types": "./dist/
|
|
18
|
+
"types": "./dist/main.d.ts",
|
|
19
19
|
"default": "./dist/index.es.js"
|
|
20
20
|
},
|
|
21
21
|
"./vite-plugins": {
|