babel-plugin-hylid-bridge 4.0.0-alpha.2 → 4.0.0-alpha.21
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.
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = _default;
|
|
8
|
+
exports.filterWhichCanIUseJsapi = filterWhichCanIUseJsapi;
|
|
9
|
+
var _path = _interopRequireDefault(require("path"));
|
|
10
|
+
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
11
|
+
var _getLibraryDir = _interopRequireDefault(require("./getLibraryDir"));
|
|
12
|
+
var _helper = require("./helper");
|
|
13
|
+
function _default(targets) {
|
|
14
|
+
var lib = (0, _getLibraryDir.default)();
|
|
15
|
+
targets = targets.map(function (item) {
|
|
16
|
+
return item.toLowerCase();
|
|
17
|
+
});
|
|
18
|
+
// 获取 lib 下的 bridge.js 文件
|
|
19
|
+
var bridgeFile = _path.default.join(lib, 'lib', 'whichCanIUse', 'compatibilities.json');
|
|
20
|
+
var compatibilities = JSON.parse(_fsExtra.default.readFileSync(bridgeFile, 'utf-8'));
|
|
21
|
+
// 获取 hylid-bridge 版本
|
|
22
|
+
var packageJsonFile = _path.default.join(lib, 'package.json');
|
|
23
|
+
var _JSON$parse = JSON.parse(_fsExtra.default.readFileSync(packageJsonFile, 'utf-8')),
|
|
24
|
+
version = _JSON$parse.version;
|
|
25
|
+
for (var api in compatibilities) {
|
|
26
|
+
var list = compatibilities[api];
|
|
27
|
+
compatibilities[api] = list.filter(function (item) {
|
|
28
|
+
if (item.deleteAt) return false;
|
|
29
|
+
if (item.hylidBridgeVersion && (0, _helper.compareVersion)(version, item.hylidBridgeVersion) < 0) return false;
|
|
30
|
+
if (!targets.includes((item.platformType + item.clientName).toLowerCase())) return false;
|
|
31
|
+
return true;
|
|
32
|
+
});
|
|
33
|
+
compatibilities[api] = list.map(function (item) {
|
|
34
|
+
return {
|
|
35
|
+
clientName: item.clientName,
|
|
36
|
+
platformType: item.platformType,
|
|
37
|
+
clientVersion: item.clientVersion,
|
|
38
|
+
osType: item.osType,
|
|
39
|
+
supported: item.supported
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
_fsExtra.default.writeFileSync(bridgeFile, JSON.stringify(compatibilities));
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
function filterWhichCanIUseJsapi(apiList) {
|
|
47
|
+
var lib = (0, _getLibraryDir.default)();
|
|
48
|
+
// 获取 lib 下的 bridge.js 文件
|
|
49
|
+
var bridgeFile = _path.default.join(lib, 'lib', 'whichCanIUse', 'compatibilities.json');
|
|
50
|
+
var compatibilities = JSON.parse(_fsExtra.default.readFileSync(bridgeFile, 'utf-8'));
|
|
51
|
+
Object.keys(compatibilities).forEach(function (api) {
|
|
52
|
+
if (!apiList.includes(api)) {
|
|
53
|
+
delete compatibilities[api];
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
_fsExtra.default.writeFileSync(bridgeFile, JSON.stringify(compatibilities));
|
|
57
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "babel-plugin-hylid-bridge",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.21",
|
|
4
4
|
"description": "babel-plugin-hylid-bridge",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/babel-plugin-tester": "^9.0.7",
|
|
24
24
|
"babel-plugin-tester": "^10.1.0",
|
|
25
|
-
"hylid-bridge": "^4.0.0-alpha.
|
|
25
|
+
"hylid-bridge": "^4.0.0-alpha.21"
|
|
26
26
|
},
|
|
27
27
|
"sideEffects": false,
|
|
28
28
|
"registry": "https://registry.npmjs.org/"
|