xctc-utils 1.6.75 → 1.6.76
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/update/index.d.ts +1 -0
- package/dist/update/index.js +15 -7
- package/package.json +3 -2
package/dist/update/index.d.ts
CHANGED
package/dist/update/index.js
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.autoUpdateLastVersion = void 0;
|
|
4
|
+
require("whatwg-fetch");
|
|
4
5
|
let autoUpdateLastSrcs;
|
|
5
6
|
let autoUpdateScriptReg = /\<script.*src=["'](?<src>[^"']+)/gm;
|
|
6
7
|
let autoUpdateDuration = 5000;
|
|
7
8
|
let autoUpdateToast = false;
|
|
8
9
|
let autoUpdateStatus = true;
|
|
9
10
|
async function getNewScripts() {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
if (typeof fetch === 'function') {
|
|
12
|
+
console.log('Browser supports fetch.');
|
|
13
|
+
const html = await fetch("/").then(res => res.text());
|
|
14
|
+
autoUpdateScriptReg['lastIndex'] = 0;
|
|
15
|
+
let result = [];
|
|
16
|
+
let match;
|
|
17
|
+
while ((match = autoUpdateScriptReg.exec(html))) {
|
|
18
|
+
result.push(match.groups.src);
|
|
19
|
+
}
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
console.log('Browser does not support fetch.');
|
|
24
|
+
return [];
|
|
16
25
|
}
|
|
17
|
-
return result;
|
|
18
26
|
}
|
|
19
27
|
async function needUpdate() {
|
|
20
28
|
const newScripts = await getNewScripts();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xctc-utils",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.6.
|
|
4
|
+
"version": "1.6.76",
|
|
5
5
|
"description": "localStorage存储\r ```\r sessionStorage存储\r ```\r crypto-js加密、解密\r ```\r 微信授权登录、微信分享\r ```\r 设备环境获取\r ```\r 是否是微信浏览器\r ```\r 时间戳转时间,字符串转时间戳",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"crypto-js": "^4.2.0",
|
|
22
|
-
"weixin-js-sdk": "^1.6.5"
|
|
22
|
+
"weixin-js-sdk": "^1.6.5",
|
|
23
|
+
"whatwg-fetch": "^3.6.20"
|
|
23
24
|
},
|
|
24
25
|
"repository": {
|
|
25
26
|
"type": "git",
|