babel-plugin-hylid-bridge 2.12.0-alpha.3 → 2.12.0-alpha.32
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/lib/combineExports.d.ts +1 -0
- package/lib/{src/combineExports.js → combineExports.js} +4 -3
- package/lib/generateJSAPIs.d.ts +1 -0
- package/lib/generateJSAPIs.js +54 -0
- package/lib/helper.d.ts +24 -0
- package/lib/helper.js +119 -0
- package/lib/{src/index.d.ts → index.d.ts} +1 -0
- package/lib/{src/index.js → index.js} +42 -106
- package/package.json +5 -3
- package/CHANGELOG.md +0 -150
- package/lib/src/combineExports.d.ts +0 -1
- package/lib/test/inedx.spec.d.ts +0 -1
- package/lib/test/inedx.spec.js +0 -45
- package/lib/test/template/user-clients/mp/alipay/index.d.ts +0 -4
- package/lib/test/template/user-clients/mp/alipay/index.js +0 -12
- /package/lib/{src/getLibraryDir.d.ts → getLibraryDir.d.ts} +0 -0
- /package/lib/{src/getLibraryDir.js → getLibraryDir.js} +0 -0
- /package/lib/{src/utils.d.ts → utils.d.ts} +0 -0
- /package/lib/{src/utils.js → utils.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function combieExports(index1Path: string, index2Path: string): string;
|
|
@@ -4,12 +4,13 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.default =
|
|
7
|
+
exports.default = combieExports;
|
|
8
8
|
var _path = _interopRequireDefault(require("path"));
|
|
9
9
|
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
10
10
|
var _hashIt = _interopRequireDefault(require("hash-it"));
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
var isTest = process.env.NODE_ENV === 'test';
|
|
12
|
+
function combieExports(index1Path, index2Path) {
|
|
13
|
+
var indexPath = _path.default.resolve(__dirname, '..', '.temp', (isTest ? 'test' : (0, _hashIt.default)("".concat(index1Path).concat(index2Path))) + '.js');
|
|
13
14
|
_fsExtra.default.ensureFileSync(indexPath);
|
|
14
15
|
_fsExtra.default.writeFileSync(indexPath, "\n import index1 from '".concat(index1Path, "';\n import index2 from '").concat(index2Path, "';\n\n export default {\n ...index1,\n ...index2,\n };\n "));
|
|
15
16
|
return indexPath;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function generateJSAPIs(targets: string[]): void;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = generateJSAPIs;
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _path = _interopRequireDefault(require("path"));
|
|
10
|
+
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
11
|
+
var _parser = require("@babel/parser");
|
|
12
|
+
var _traverse = _interopRequireDefault(require("@babel/traverse"));
|
|
13
|
+
var _generator = _interopRequireDefault(require("@babel/generator"));
|
|
14
|
+
var _getLibraryDir = _interopRequireDefault(require("./getLibraryDir"));
|
|
15
|
+
var _helper = require("./helper");
|
|
16
|
+
function generateJSAPIs(targets) {
|
|
17
|
+
var lib = (0, _getLibraryDir.default)();
|
|
18
|
+
// 获取当前配置的环境信息
|
|
19
|
+
var appEnvList = targets.reduce(function (acc, target) {
|
|
20
|
+
var _splitTarget = (0, _helper.splitTarget)(target),
|
|
21
|
+
_splitTarget2 = (0, _slicedToArray2.default)(_splitTarget, 2),
|
|
22
|
+
platform = _splitTarget2[0],
|
|
23
|
+
client = _splitTarget2[1];
|
|
24
|
+
acc.push("".concat((0, _helper.camelCase)("is_".concat(platform, "_").concat(client))));
|
|
25
|
+
return acc;
|
|
26
|
+
}, []);
|
|
27
|
+
// 获取 lib 下的 bridge.js 文件
|
|
28
|
+
var bridgeFile = _path.default.join(lib, 'lib', 'bridges.js');
|
|
29
|
+
var ast = (0, _parser.parse)(_fsExtra.default.readFileSync(bridgeFile, 'utf-8'), {
|
|
30
|
+
sourceType: 'module'
|
|
31
|
+
});
|
|
32
|
+
(0, _traverse.default)(ast, {
|
|
33
|
+
IfStatement: function IfStatement(path) {
|
|
34
|
+
/**
|
|
35
|
+
* if 条件里有 n 多种写法,test 对应 n 多中类型。
|
|
36
|
+
* 下面为了方便,直接尝试访问 object.name 是否是 appEnv,在 bridge.js 中,符合这个条件的,一定是 jsapi 函数中 if 判断条件
|
|
37
|
+
*/
|
|
38
|
+
var _ref = path.node.test || {},
|
|
39
|
+
object = _ref.object,
|
|
40
|
+
property = _ref.property;
|
|
41
|
+
if ((object === null || object === void 0 ? void 0 : object.name) === 'appEnv') {
|
|
42
|
+
var env = property.name;
|
|
43
|
+
// 删除不是目标的 appEnv 判断代码
|
|
44
|
+
if (!appEnvList.includes(env)) {
|
|
45
|
+
path.remove();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
// 生成文件
|
|
51
|
+
var outPath = _path.default.join(lib, 'lib', 'babel-plugin-compact.js');
|
|
52
|
+
var codes = ['// hylid-bridge babel 插件生成', "export * from './index'", "export { default } from './index'", (0, _generator.default)(ast).code];
|
|
53
|
+
_fsExtra.default.writeFileSync(outPath, codes.join('\n'));
|
|
54
|
+
}
|
package/lib/helper.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type babelCore from '@babel/core';
|
|
2
|
+
import { PluginPass } from '@babel/core';
|
|
3
|
+
export declare function snakeCaseTarget(input: string): string;
|
|
4
|
+
export declare function isTargetSupported(target: string, libraryDir: string): boolean;
|
|
5
|
+
export declare function getTargets(libraryDir: string, customTargets?: string[]): string[];
|
|
6
|
+
export declare function isApiExists(name: string, target: string, libraryDir: string, polyfillDir?: string): boolean | "" | undefined;
|
|
7
|
+
export declare function getUserAppEnvPath(appEnvPath?: string): string | undefined;
|
|
8
|
+
export declare function splitTarget(target: string): string[];
|
|
9
|
+
interface IState extends PluginPass {
|
|
10
|
+
usedJSAPIList: 'all' | string[];
|
|
11
|
+
}
|
|
12
|
+
export declare function getNames(node: babelCore.NodePath<babelCore.types.MemberExpression>['node'], scope: babelCore.NodePath<babelCore.types.MemberExpression>['scope'], state: IState, targets: string[]): {
|
|
13
|
+
objectName: string;
|
|
14
|
+
propertyName: undefined;
|
|
15
|
+
} | {
|
|
16
|
+
objectName: string;
|
|
17
|
+
propertyName: string;
|
|
18
|
+
} | {
|
|
19
|
+
objectName: undefined;
|
|
20
|
+
propertyName: undefined;
|
|
21
|
+
};
|
|
22
|
+
export declare function isJSAPIInTargets(jsapiName: string, targets: string[], filename: string, libraryDir: string, polyfillDir?: string): boolean;
|
|
23
|
+
export declare function camelCase(input: string): string;
|
|
24
|
+
export {};
|
package/lib/helper.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.camelCase = camelCase;
|
|
9
|
+
exports.getNames = getNames;
|
|
10
|
+
exports.getTargets = getTargets;
|
|
11
|
+
exports.getUserAppEnvPath = getUserAppEnvPath;
|
|
12
|
+
exports.isApiExists = isApiExists;
|
|
13
|
+
exports.isJSAPIInTargets = isJSAPIInTargets;
|
|
14
|
+
exports.isTargetSupported = isTargetSupported;
|
|
15
|
+
exports.snakeCaseTarget = snakeCaseTarget;
|
|
16
|
+
exports.splitTarget = splitTarget;
|
|
17
|
+
var _path = _interopRequireDefault(require("path"));
|
|
18
|
+
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
19
|
+
var utils = _interopRequireWildcard(require("./utils"));
|
|
20
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
21
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
22
|
+
function snakeCaseTarget(input) {
|
|
23
|
+
var words = input.replace(/[^a-zA-Z0-9]+/g, ' ').trim();
|
|
24
|
+
var wordArray = words.split(' ');
|
|
25
|
+
var snakeCasedWords = wordArray.map(function (word) {
|
|
26
|
+
return word.replace(/[A-Z]/g, function (match, index) {
|
|
27
|
+
return index === 0 ? match.toLowerCase() : "_".concat(match);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
return snakeCasedWords.join('_');
|
|
31
|
+
}
|
|
32
|
+
function isTargetSupported(target, libraryDir) {
|
|
33
|
+
return ['MpWeb', 'Mp', 'Web'].some(function (prefix) {
|
|
34
|
+
if (target.startsWith(prefix)) {
|
|
35
|
+
var targetClientDir = _path.default.resolve(libraryDir, 'lib/clients', snakeCaseTarget(prefix), snakeCaseTarget(target.replace(prefix, '')));
|
|
36
|
+
return _fsExtra.default.existsSync(targetClientDir);
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function getTargets(libraryDir, customTargets) {
|
|
42
|
+
var targets = customTargets || (process.env.HYLID_BRIDGE_TARGETS ? process.env.HYLID_BRIDGE_TARGETS.split(',') : []);
|
|
43
|
+
return targets.filter(function (target) {
|
|
44
|
+
return isTargetSupported(target, libraryDir);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function isApiExists(name, target, libraryDir, polyfillDir) {
|
|
48
|
+
var targetSplit = splitTarget(target);
|
|
49
|
+
if (targetSplit.length !== 2) {
|
|
50
|
+
throw new Error("Wrong target configuration: ".concat(target, "."));
|
|
51
|
+
}
|
|
52
|
+
return _fsExtra.default.existsSync(_path.default.resolve(libraryDir, "./lib/clients/".concat(targetSplit[0], "/").concat(targetSplit[1], "/").concat(name, ".js"))) || polyfillDir && (_fsExtra.default.existsSync(_path.default.resolve(polyfillDir, "./".concat(targetSplit[0], "/").concat(targetSplit[1], "/").concat(name, ".js"))) || _fsExtra.default.existsSync(_path.default.resolve(polyfillDir, "./".concat(targetSplit[0], "/").concat(targetSplit[1], "/").concat(name, ".ts"))));
|
|
53
|
+
}
|
|
54
|
+
function getUserAppEnvPath(appEnvPath) {
|
|
55
|
+
var realAppEnvPath = appEnvPath !== null && appEnvPath !== void 0 ? appEnvPath : _path.default.resolve(process.cwd(), './src/appEnv.ts');
|
|
56
|
+
if (!_fsExtra.default.existsSync(realAppEnvPath)) {
|
|
57
|
+
utils.log("Can not find the appEnv module at the path: ".concat(realAppEnvPath, "."));
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
return realAppEnvPath;
|
|
61
|
+
}
|
|
62
|
+
function splitTarget(target) {
|
|
63
|
+
var prefixList = ['MpWeb', 'Mp', 'Web'];
|
|
64
|
+
for (var i = 0, il = prefixList.length; i < il; i++) {
|
|
65
|
+
var prefix = prefixList[i];
|
|
66
|
+
if (target.startsWith(prefix)) {
|
|
67
|
+
return [snakeCaseTarget(prefix), snakeCaseTarget(target.replace(prefix, ''))];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
throw new Error("Invalid bridge target: ".concat(target, "."));
|
|
71
|
+
}
|
|
72
|
+
function getNames(node, scope, state, targets) {
|
|
73
|
+
var _state$filename;
|
|
74
|
+
// my.alert || my[a]
|
|
75
|
+
if (node.object.type === 'Identifier' && node.property.type === 'Identifier' &&
|
|
76
|
+
// Remix 中会编译所有 node_modules 下的模块
|
|
77
|
+
!((_state$filename = state.filename) !== null && _state$filename !== void 0 && _state$filename.includes("".concat(_path.default.sep, "node_modules").concat(_path.default.sep, "hylid-bridge").concat(_path.default.sep))) && targets && targets.length && !scope.hasBinding('my')) {
|
|
78
|
+
return node.computed ? {
|
|
79
|
+
objectName: node.object.name,
|
|
80
|
+
propertyName: undefined
|
|
81
|
+
} : {
|
|
82
|
+
objectName: node.object.name,
|
|
83
|
+
propertyName: node.property.name
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
// my['alert']
|
|
87
|
+
if (node.object.type === 'Identifier' && node.property.type === 'StringLiteral' && node.computed && targets && targets.length && !scope.hasBinding('my')) {
|
|
88
|
+
return {
|
|
89
|
+
objectName: node.object.name,
|
|
90
|
+
propertyName: node.property.value
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
objectName: undefined,
|
|
95
|
+
propertyName: undefined
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function isJSAPIInTargets(jsapiName, targets, filename, libraryDir, polyfillDir) {
|
|
99
|
+
return targets.every(function (target) {
|
|
100
|
+
var targetSplit = splitTarget(target);
|
|
101
|
+
if (!isApiExists(jsapiName, target, libraryDir, polyfillDir)) {
|
|
102
|
+
utils.warn("Can not find the API `".concat(jsapiName, "` in `").concat(_path.default.resolve(libraryDir, './lib/clients/' + targetSplit[0] + '/' + targetSplit[1]), "`. Fallback to import all API codes of ").concat(target, ". Current file path: `").concat(filename, "`."));
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
return true;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
// lodash 把数字后面第一个字符变大了,所以这里单独实现下
|
|
109
|
+
function camelCase(input) {
|
|
110
|
+
var words = input.replace(/[^a-zA-Z0-9]+/g, ' ').trim();
|
|
111
|
+
var wordArray = words.split(' ');
|
|
112
|
+
var camelCasedWords = wordArray.map(function (word, index) {
|
|
113
|
+
if (index === 0) {
|
|
114
|
+
return word.toLowerCase();
|
|
115
|
+
}
|
|
116
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
117
|
+
});
|
|
118
|
+
return camelCasedWords.join('');
|
|
119
|
+
}
|
|
@@ -14,111 +14,45 @@ var babelTypes = _interopRequireWildcard(require("@babel/types"));
|
|
|
14
14
|
var _getLibraryDir = _interopRequireDefault(require("./getLibraryDir"));
|
|
15
15
|
var utils = _interopRequireWildcard(require("./utils"));
|
|
16
16
|
var _combineExports = _interopRequireDefault(require("./combineExports"));
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
var _helper = require("./helper");
|
|
18
|
+
var _generateJSAPIs = _interopRequireDefault(require("./generateJSAPIs"));
|
|
19
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
20
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
19
21
|
/**
|
|
20
22
|
* https://astexplorer.net/
|
|
21
23
|
*/
|
|
22
24
|
|
|
23
25
|
var identifierPrefix = '__hylid_bridge__';
|
|
24
26
|
var libraryName = 'hylid-bridge';
|
|
25
|
-
function snakeCaseTarget(value) {
|
|
26
|
-
if (value === 'H5') {
|
|
27
|
-
return 'h5';
|
|
28
|
-
}
|
|
29
|
-
return _lodash.default.snakeCase(value);
|
|
30
|
-
}
|
|
31
|
-
function isTargetSupported(target, libraryDir) {
|
|
32
|
-
return ['MpWeb', 'Mp', 'Web'].some(function (prefix) {
|
|
33
|
-
if (target.startsWith(prefix)) {
|
|
34
|
-
var targetClientDir = _path.default.resolve(libraryDir, 'lib/clients', snakeCaseTarget(prefix), snakeCaseTarget(target.replace(prefix, '')));
|
|
35
|
-
return _fsExtra.default.existsSync(targetClientDir);
|
|
36
|
-
}
|
|
37
|
-
return false;
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
function getTargets(libraryDir, customTargets) {
|
|
41
|
-
var targets = customTargets || (process.env.HYLID_BRIDGE_TARGETS ? process.env.HYLID_BRIDGE_TARGETS.split(',') : []);
|
|
42
|
-
return targets.filter(function (target) {
|
|
43
|
-
return isTargetSupported(target, libraryDir);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
function isApiExists(name, target, libraryDir, polyfillDir) {
|
|
47
|
-
var targetSplit = splitTarget(target);
|
|
48
|
-
if (targetSplit.length !== 2) {
|
|
49
|
-
throw new Error("Wrong target configuration: ".concat(target, "."));
|
|
50
|
-
}
|
|
51
|
-
return _fsExtra.default.existsSync(_path.default.resolve(libraryDir, "./lib/clients/".concat(targetSplit[0], "/").concat(targetSplit[1], "/").concat(name, ".js"))) || polyfillDir && _fsExtra.default.existsSync(_path.default.resolve(polyfillDir, "./".concat(targetSplit[0], "/").concat(targetSplit[1], "/").concat(name, ".js")));
|
|
52
|
-
}
|
|
53
|
-
function getUserAppEnvPath(appEnvPath) {
|
|
54
|
-
var realAppEnvPath = appEnvPath !== null && appEnvPath !== void 0 ? appEnvPath : _path.default.resolve(process.cwd(), './src/appEnv.ts');
|
|
55
|
-
if (!_fsExtra.default.existsSync(realAppEnvPath)) {
|
|
56
|
-
utils.log("Can not find the appEnv module at the path: ".concat(realAppEnvPath, "."));
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
return realAppEnvPath;
|
|
60
|
-
}
|
|
61
|
-
function splitTarget(target) {
|
|
62
|
-
var prefixList = ['MpWeb', 'Mp', 'Web'];
|
|
63
|
-
for (var i = 0, il = prefixList.length; i < il; i++) {
|
|
64
|
-
var prefix = prefixList[i];
|
|
65
|
-
if (target.startsWith(prefix)) {
|
|
66
|
-
return [snakeCaseTarget(prefix), snakeCaseTarget(target.replace(prefix, ''))];
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
throw new Error("Invalid bridge target: ".concat(target, "."));
|
|
70
|
-
}
|
|
71
27
|
var myLocalName = "".concat(identifierPrefix, "my__");
|
|
72
|
-
function
|
|
73
|
-
var
|
|
74
|
-
// my.alert || my[a]
|
|
75
|
-
if (node.object.type === 'Identifier' && node.property.type === 'Identifier' &&
|
|
76
|
-
// Remix 中会编译所有 node_modules 下的模块
|
|
77
|
-
!((_state$filename = state.filename) !== null && _state$filename !== void 0 && _state$filename.includes("".concat(_path.default.sep, "node_modules").concat(_path.default.sep, "hylid-bridge").concat(_path.default.sep))) && targets && targets.length && !scope.hasBinding('my')) {
|
|
78
|
-
return node.computed ? {
|
|
79
|
-
objectName: node.object.name,
|
|
80
|
-
propertyName: undefined
|
|
81
|
-
} : {
|
|
82
|
-
objectName: node.object.name,
|
|
83
|
-
propertyName: node.property.name
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
// my['alert']
|
|
87
|
-
if (node.object.type === 'Identifier' && node.property.type === 'StringLiteral' && node.computed && targets && targets.length && !scope.hasBinding('my')) {
|
|
88
|
-
return {
|
|
89
|
-
objectName: node.object.name,
|
|
90
|
-
propertyName: node.property.value
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
return {
|
|
94
|
-
objectName: undefined,
|
|
95
|
-
propertyName: undefined
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
function isJSAPIInTargets(jsapiName, targets, filename, libraryDir, polyfillDir) {
|
|
99
|
-
return targets.every(function (target) {
|
|
100
|
-
var targetSplit = splitTarget(target);
|
|
101
|
-
if (!isApiExists(jsapiName, target, libraryDir, polyfillDir)) {
|
|
102
|
-
utils.warn("Can not find the API `".concat(jsapiName, "` in `").concat(_path.default.resolve(libraryDir, './lib/clients/' + targetSplit[0] + '/' + targetSplit[1]), "`. Fallback to import all API codes of ").concat(target, ". Current file path: `").concat(filename, "`."));
|
|
103
|
-
return false;
|
|
104
|
-
}
|
|
105
|
-
return true;
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
var _default = function _default(core, opts) {
|
|
109
|
-
var _opts$libraryDir;
|
|
28
|
+
var _default = exports.default = function _default(core, opts) {
|
|
29
|
+
var _opts$libraryDir, _opts$transformMy;
|
|
110
30
|
var libraryDir = (_opts$libraryDir = opts === null || opts === void 0 ? void 0 : opts.libraryDir) !== null && _opts$libraryDir !== void 0 ? _opts$libraryDir : (0, _getLibraryDir.default)();
|
|
111
|
-
var targets = getTargets(libraryDir, opts === null || opts === void 0 ? void 0 : opts.targets);
|
|
112
|
-
var userAppEnvPath = getUserAppEnvPath(opts === null || opts === void 0 ? void 0 : opts.appEnvPath);
|
|
31
|
+
var targets = (0, _helper.getTargets)(libraryDir, opts === null || opts === void 0 ? void 0 : opts.targets);
|
|
32
|
+
var userAppEnvPath = (0, _helper.getUserAppEnvPath)(opts === null || opts === void 0 ? void 0 : opts.appEnvPath);
|
|
113
33
|
var polyfillDir = opts === null || opts === void 0 ? void 0 : opts.polyfillDir;
|
|
34
|
+
var transformMy = (_opts$transformMy = opts === null || opts === void 0 ? void 0 : opts.transformMy) !== null && _opts$transformMy !== void 0 ? _opts$transformMy : false;
|
|
35
|
+
// 生成 babel-plugin-compact 文件
|
|
36
|
+
(0, _generateJSAPIs.default)(targets);
|
|
114
37
|
return {
|
|
115
38
|
name: 'babel-plugin-hylid-bridge',
|
|
116
39
|
visitor: {
|
|
40
|
+
ImportDeclaration: function ImportDeclaration(path) {
|
|
41
|
+
if (path.node.source.value === libraryName) {
|
|
42
|
+
path.node.source = core.types.stringLiteral("".concat(libraryName, "/babel-plugin-compact"));
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
ExportNamedDeclaration: function ExportNamedDeclaration(path) {
|
|
46
|
+
var _path$node$source;
|
|
47
|
+
if (((_path$node$source = path.node.source) === null || _path$node$source === void 0 ? void 0 : _path$node$source.value) === libraryName) {
|
|
48
|
+
path.node.source = core.types.stringLiteral("".concat(libraryName, "/babel-plugin-compact"));
|
|
49
|
+
}
|
|
50
|
+
},
|
|
117
51
|
MemberExpression: function MemberExpression(path, state) {
|
|
118
|
-
var _getNames = getNames(path.node, path.scope, state, targets),
|
|
52
|
+
var _getNames = (0, _helper.getNames)(path.node, path.scope, state, targets),
|
|
119
53
|
objectName = _getNames.objectName,
|
|
120
54
|
propertyName = _getNames.propertyName;
|
|
121
|
-
if (propertyName === 'call' || objectName !== 'my') {
|
|
55
|
+
if (propertyName === 'call' || objectName !== 'my' || !transformMy) {
|
|
122
56
|
return;
|
|
123
57
|
}
|
|
124
58
|
var newNode = core.types.cloneNode(path.node, true, true);
|
|
@@ -136,7 +70,7 @@ var _default = function _default(core, opts) {
|
|
|
136
70
|
if (propertyName) {
|
|
137
71
|
state.usedJSAPIList = state.usedJSAPIList || [];
|
|
138
72
|
var name = propertyName;
|
|
139
|
-
if (isJSAPIInTargets(name, targets, state.filename, libraryDir, polyfillDir)) {
|
|
73
|
+
if ((0, _helper.isJSAPIInTargets)(name, targets, state.filename, libraryDir, polyfillDir)) {
|
|
140
74
|
state.usedJSAPIList.push(name);
|
|
141
75
|
} else {
|
|
142
76
|
state.usedJSAPIList = 'all';
|
|
@@ -146,23 +80,25 @@ var _default = function _default(core, opts) {
|
|
|
146
80
|
}
|
|
147
81
|
},
|
|
148
82
|
CallExpression: function CallExpression(path, state) {
|
|
149
|
-
if (path.node.callee.type !== 'MemberExpression') {
|
|
83
|
+
if (path.node.callee.type !== 'MemberExpression' || !transformMy) {
|
|
150
84
|
return;
|
|
151
85
|
}
|
|
152
|
-
var _getNames2 = getNames(path.node.callee, path.scope, state, targets),
|
|
86
|
+
var _getNames2 = (0, _helper.getNames)(path.node.callee, path.scope, state, targets),
|
|
153
87
|
objectName = _getNames2.objectName,
|
|
154
88
|
propertyName = _getNames2.propertyName;
|
|
155
89
|
if (objectName !== 'my' || propertyName !== 'call' || !path.node.arguments[0] || path.node.arguments[0].type !== 'StringLiteral') {
|
|
156
90
|
return;
|
|
157
91
|
}
|
|
158
|
-
var newNode = core.types.callExpression(
|
|
92
|
+
var newNode = core.types.callExpression(
|
|
93
|
+
// @ts-ignore
|
|
94
|
+
babelTypes.memberExpression(babelTypes.identifier(myLocalName), babelTypes.identifier(path.node.arguments[0].value)), path.node.arguments.slice(1));
|
|
159
95
|
if (state.usedJSAPIList === 'all') {
|
|
160
96
|
path.replaceWith(newNode);
|
|
161
97
|
return;
|
|
162
98
|
}
|
|
163
99
|
state.usedJSAPIList = state.usedJSAPIList || [];
|
|
164
100
|
var name = path.node.arguments[0].value;
|
|
165
|
-
if (isJSAPIInTargets(name, targets, state.filename, libraryDir, polyfillDir)) {
|
|
101
|
+
if ((0, _helper.isJSAPIInTargets)(name, targets, state.filename, libraryDir, polyfillDir)) {
|
|
166
102
|
state.usedJSAPIList.push(name);
|
|
167
103
|
} else {
|
|
168
104
|
state.usedJSAPIList = 'all';
|
|
@@ -192,9 +128,10 @@ var _default = function _default(core, opts) {
|
|
|
192
128
|
nodes.push(babelTypes.importDeclaration([babelTypes.importDefaultSpecifier(babelTypes.identifier(objectSpreadName))], babelTypes.stringLiteral("".concat(libraryName, "/lib/objectSpread"))), babelTypes.variableDeclaration('var', [babelTypes.variableDeclarator(babelTypes.identifier(appEnvLocalName), babelTypes.callExpression(babelTypes.identifier(objectSpreadName), [babelTypes.identifier(innerAppEnvLocalName), babelTypes.identifier(userAppEnvLocalName)]))]));
|
|
193
129
|
if (usedJSAPIList === 'all') {
|
|
194
130
|
nodes.push.apply(nodes, (0, _toConsumableArray2.default)(targets.map(function (target) {
|
|
195
|
-
var targetSplit = splitTarget(target);
|
|
131
|
+
var targetSplit = (0, _helper.splitTarget)(target);
|
|
196
132
|
var innerIndexPath = "".concat(libraryName, "/lib/clients/").concat(targetSplit[0], "/").concat(targetSplit[1], "/index");
|
|
197
|
-
var
|
|
133
|
+
var polyfillIndexPath = polyfillDir && _path.default.resolve(polyfillDir, targetSplit[0], targetSplit[1], 'index');
|
|
134
|
+
var normalizedIndexPath = polyfillIndexPath && (_fsExtra.default.existsSync("".concat(polyfillIndexPath, ".js")) || _fsExtra.default.existsSync("".concat(polyfillIndexPath, ".ts"))) ? (0, _combineExports.default)(require.resolve(innerIndexPath), polyfillIndexPath) : innerIndexPath;
|
|
198
135
|
return babelTypes.importDeclaration([babelTypes.importDefaultSpecifier(babelTypes.identifier("".concat(identifierPrefix).concat(targetSplit[0], "_").concat(targetSplit[1], "_my__")))], babelTypes.stringLiteral(normalizedIndexPath));
|
|
199
136
|
})));
|
|
200
137
|
var buildElseIf = function buildElseIf(targetList) {
|
|
@@ -202,13 +139,13 @@ var _default = function _default(core, opts) {
|
|
|
202
139
|
return;
|
|
203
140
|
}
|
|
204
141
|
var target = targetList[0];
|
|
205
|
-
var targetSplit = splitTarget(target);
|
|
206
|
-
return babelTypes.ifStatement(babelTypes.identifier("".concat(appEnvLocalName, ".").concat(
|
|
142
|
+
var targetSplit = (0, _helper.splitTarget)(target);
|
|
143
|
+
return babelTypes.ifStatement(babelTypes.identifier("".concat(appEnvLocalName, ".").concat((0, _helper.camelCase)("is_".concat(targetSplit[0], "_").concat(targetSplit[1])))), babelTypes.blockStatement([babelTypes.expressionStatement(babelTypes.assignmentExpression('=', babelTypes.identifier(myLocalName), babelTypes.identifier("".concat(identifierPrefix).concat(targetSplit[0], "_").concat(targetSplit[1], "_my__"))))]), buildElseIf(targetList.slice(1)));
|
|
207
144
|
};
|
|
208
145
|
nodes.push(babelTypes.variableDeclaration('var', [babelTypes.variableDeclarator(babelTypes.identifier(myLocalName))]));
|
|
209
146
|
// Do not generate the `if statement` when there is just one target.
|
|
210
147
|
if (targets.length === 1) {
|
|
211
|
-
var targetSplit = splitTarget(targets[0]);
|
|
148
|
+
var targetSplit = (0, _helper.splitTarget)(targets[0]);
|
|
212
149
|
nodes.push(babelTypes.expressionStatement(babelTypes.assignmentExpression('=', babelTypes.identifier(myLocalName), babelTypes.identifier("".concat(identifierPrefix).concat(targetSplit[0], "_").concat(targetSplit[1], "_my__")))));
|
|
213
150
|
} else {
|
|
214
151
|
var elseIfNode = buildElseIf(targets);
|
|
@@ -218,7 +155,7 @@ var _default = function _default(core, opts) {
|
|
|
218
155
|
var normalizedJSAPIList = _lodash.default.uniq(usedJSAPIList);
|
|
219
156
|
normalizedJSAPIList.forEach(function (name) {
|
|
220
157
|
targets.forEach(function (target) {
|
|
221
|
-
var targetSplit = splitTarget(target);
|
|
158
|
+
var targetSplit = (0, _helper.splitTarget)(target);
|
|
222
159
|
var localName = "".concat(identifierPrefix).concat(targetSplit[0], "_").concat(targetSplit[1], "_").concat(name, "__");
|
|
223
160
|
var innerSourcePath = "".concat(libraryName, "/lib/clients/").concat(targetSplit[0], "/").concat(targetSplit[1], "/").concat(name);
|
|
224
161
|
var userSourcePath = polyfillDir ? _path.default.resolve(polyfillDir, targetSplit[0], targetSplit[1], name) : undefined;
|
|
@@ -231,16 +168,16 @@ var _default = function _default(core, opts) {
|
|
|
231
168
|
return;
|
|
232
169
|
}
|
|
233
170
|
var target = targetList[0];
|
|
234
|
-
var targetSplit = splitTarget(target);
|
|
171
|
+
var targetSplit = (0, _helper.splitTarget)(target);
|
|
235
172
|
var propertyList = normalizedJSAPIList.map(function (name) {
|
|
236
173
|
return babelTypes.objectProperty(babelTypes.identifier(name), babelTypes.identifier("".concat(identifierPrefix).concat(targetSplit[0], "_").concat(targetSplit[1], "_").concat(name, "__")));
|
|
237
174
|
});
|
|
238
|
-
return babelTypes.ifStatement(babelTypes.identifier("".concat(appEnvLocalName, ".").concat(
|
|
175
|
+
return babelTypes.ifStatement(babelTypes.identifier("".concat(appEnvLocalName, ".").concat((0, _helper.camelCase)("is_".concat(targetSplit[0], "_").concat(targetSplit[1])))), babelTypes.blockStatement([babelTypes.expressionStatement(babelTypes.assignmentExpression('=', babelTypes.identifier(myLocalName), babelTypes.objectExpression(propertyList)))]), _buildElseIf(targetList.slice(1)));
|
|
239
176
|
};
|
|
240
177
|
nodes.push(babelTypes.variableDeclaration('var', [babelTypes.variableDeclarator(babelTypes.identifier(myLocalName))]));
|
|
241
178
|
// Do not generate the `if statement` when there is just one target.
|
|
242
179
|
if (targets.length === 1) {
|
|
243
|
-
var _targetSplit = splitTarget(targets[0]);
|
|
180
|
+
var _targetSplit = (0, _helper.splitTarget)(targets[0]);
|
|
244
181
|
var propertyList = normalizedJSAPIList.map(function (name) {
|
|
245
182
|
return babelTypes.objectProperty(babelTypes.identifier(name), babelTypes.identifier("".concat(identifierPrefix).concat(_targetSplit[0], "_").concat(_targetSplit[1], "_").concat(name, "__")));
|
|
246
183
|
});
|
|
@@ -260,5 +197,4 @@ var _default = function _default(core, opts) {
|
|
|
260
197
|
}
|
|
261
198
|
}
|
|
262
199
|
};
|
|
263
|
-
};
|
|
264
|
-
exports.default = _default;
|
|
200
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "babel-plugin-hylid-bridge",
|
|
3
|
-
"version": "2.12.0-alpha.
|
|
3
|
+
"version": "2.12.0-alpha.32",
|
|
4
4
|
"description": "babel-plugin-hylid-bridge",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -20,9 +20,11 @@
|
|
|
20
20
|
"lodash": "4.17.21"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
+
"@types/babel-plugin-tester": "^9.0.7",
|
|
23
24
|
"babel-plugin-tester": "^10.1.0",
|
|
24
|
-
"hylid-bridge": "^2.12.0-alpha.
|
|
25
|
+
"hylid-bridge": "^2.12.0-alpha.32"
|
|
25
26
|
},
|
|
26
27
|
"sideEffects": false,
|
|
27
|
-
"registry": "https://registry.npmjs.org/"
|
|
28
|
+
"registry": "https://registry.npmjs.org/",
|
|
29
|
+
"repository": "https://code.alipay.com/ant-ife/hylid-bridge.git"
|
|
28
30
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
6
|
-
## [2.12.0-alpha.3] (2023-07-20)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
### Bug Fixes
|
|
10
|
-
|
|
11
|
-
* type error
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
## [2.12.0-alpha.2] (2023-07-20)
|
|
16
|
-
|
|
17
|
-
**Note:** Version bump only for package babel-plugin-hylid-bridge
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
## [2.12.0-alpha.1] (2023-07-19)
|
|
24
|
-
|
|
25
|
-
**Note:** Version bump only for package babel-plugin-hylid-bridge
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
## [2.12.0-alpha.0] (2023-07-19)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
### Features
|
|
35
|
-
|
|
36
|
-
* 升级版本号
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
## [2.10.0] (2023-02-22)
|
|
41
|
-
|
|
42
|
-
**Note:** Version bump only for package babel-plugin-hylid-bridge
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
## [2.9.0](https://code.alipay.com/ant-ife/hylid-bridge/compare/v2.9.0-alpha.0...v2.9.0) (2022-11-09)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
### Bug Fixes
|
|
52
|
-
|
|
53
|
-
* 类型兼容
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
## [2.9.0-alpha.0](https://code.alipay.com/ant-ife/hylid-bridge/compare/v2.8.0...v2.9.0-alpha.0) (2022-11-09)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
### Features
|
|
60
|
-
|
|
61
|
-
* 支持 my.call 调用
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
## [2.4.0](https://code.alipay.com/ant-ife/hylid-bridge/compare/v2.4.0-alpha.4...v2.4.0) (2022-08-18)
|
|
65
|
-
|
|
66
|
-
**Note:** Version bump only for package babel-plugin-hylid-bridge
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
## [2.4.0-alpha.4](https://code.alipay.com/ant-ife/hylid-bridge/compare/v2.1.0...v2.4.0-alpha.4) (2022-08-18)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
### Features
|
|
76
|
-
|
|
77
|
-
* 避免频繁打印日志* 不修改全局的 my, 新建本地变量* 调整 eslint 配置* 根据源码注入 hylid-bridge 相应模块* 固定三方依赖版本号* 适配 Remix 中会编译所有 node_modules 下模块的逻辑
|
|
78
|
-
|
|
79
|
-
### Bug Fixes
|
|
80
|
-
|
|
81
|
-
* 依赖* build error* split the target
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
## [2.4.0-alpha.3](https://code.alipay.com/ant-ife/hylid-bridge/compare/v2.4.0-alpha.2...v2.4.0-alpha.3) (2022-08-17)
|
|
85
|
-
|
|
86
|
-
**Note:** Version bump only for package babel-plugin-hylid-bridge
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
## [2.4.0-alpha.2](https://code.alipay.com/ant-ife/hylid-bridge/compare/v2.4.0-alpha.1...v2.4.0-alpha.2) (2022-08-16)
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
### Features
|
|
96
|
-
|
|
97
|
-
* 避免频繁打印日志* 适配 Remix 中会编译所有 node_modules 下模块的逻辑
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
## [2.4.0-alpha.1](https://code.alipay.com/ant-ife/hylid-bridge/compare/v2.4.0-alpha.0...v2.4.0-alpha.1) (2022-08-15)
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
### Features
|
|
104
|
-
|
|
105
|
-
* 不修改全局的 my, 新建本地变量
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
## [2.4.0-alpha.0](https://code.alipay.com/ant-ife/hylid-bridge/compare/v2.1.0...v2.4.0-alpha.0) (2022-08-12)
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
### Features
|
|
112
|
-
|
|
113
|
-
* 调整 eslint 配置* 根据源码注入 hylid-bridge 相应模块* 固定三方依赖版本号
|
|
114
|
-
|
|
115
|
-
### Bug Fixes
|
|
116
|
-
|
|
117
|
-
* 依赖* build error* split the target
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
## [2.3.0](https://code.alipay.com/ant-ife/hylid-bridge/compare/v2.1.0...v2.3.0) (2022-08-05)
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
### Features
|
|
124
|
-
|
|
125
|
-
* 调整 eslint 配置
|
|
126
|
-
|
|
127
|
-
### Bug Fixes
|
|
128
|
-
|
|
129
|
-
* 依赖* build error* split the target
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
## [2.2.0](https://code.alipay.com/ant-ife/hylid-bridge/compare/v2.1.0...v2.2.0) (2022-07-08)
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
### Features
|
|
136
|
-
|
|
137
|
-
* 调整 eslint 配置
|
|
138
|
-
|
|
139
|
-
### Bug Fixes
|
|
140
|
-
|
|
141
|
-
* 依赖* build error* split the target
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
# [2.1.0](https://code.alipay.com/ant-ife/hylid-bridge/compare/v1.1.0...v2.1.0) (2022-04-25)
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
### Features
|
|
148
|
-
|
|
149
|
-
* 接入 babel 插件 ([fdb8885](https://code.alipay.com/ant-ife/hylid-bridge/commits/fdb8885c6d7f16b8fbc528540ff3b397096da60b))
|
|
150
|
-
* 统一版本号 ([7539c2f](https://code.alipay.com/ant-ife/hylid-bridge/commits/7539c2f9fa4646fde964b609259e61d5e008c511))
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function combileExports(index1Path: string, index2Path: string): string;
|
package/lib/test/inedx.spec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/test/inedx.spec.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _path = _interopRequireDefault(require("path"));
|
|
5
|
-
var _babelPluginTester = _interopRequireDefault(require("babel-plugin-tester"));
|
|
6
|
-
var _src = _interopRequireDefault(require("../src"));
|
|
7
|
-
(0, _babelPluginTester.default)({
|
|
8
|
-
plugin: _src.default,
|
|
9
|
-
pluginName: 'babel-plugin-hylid-bridge',
|
|
10
|
-
pluginOptions: {
|
|
11
|
-
targets: ['WebH5', 'MpAlipay'],
|
|
12
|
-
libraryDir: _path.default.dirname(require.resolve('hylid-bridge/package.json'))
|
|
13
|
-
},
|
|
14
|
-
snapshot: true,
|
|
15
|
-
tests: [{
|
|
16
|
-
title: 'should transform the alert.',
|
|
17
|
-
code: 'my.alert()'
|
|
18
|
-
}, {
|
|
19
|
-
title: 'should transform the string literal rpc.',
|
|
20
|
-
code: "my['rpc']()"
|
|
21
|
-
}]
|
|
22
|
-
});
|
|
23
|
-
(0, _babelPluginTester.default)({
|
|
24
|
-
plugin: _src.default,
|
|
25
|
-
pluginName: 'babel-plugin-hylid-bridge',
|
|
26
|
-
pluginOptions: {
|
|
27
|
-
targets: ['MpAlipay'],
|
|
28
|
-
libraryDir: _path.default.dirname(require.resolve('hylid-bridge/package.json')),
|
|
29
|
-
polyfillDir: _path.default.resolve(__dirname, './template/user-clients')
|
|
30
|
-
},
|
|
31
|
-
snapshot: true,
|
|
32
|
-
tests: [{
|
|
33
|
-
title: 'should use the custom alert.',
|
|
34
|
-
code: 'my.alert()'
|
|
35
|
-
}, {
|
|
36
|
-
title: 'should use the inner rpc',
|
|
37
|
-
code: 'my.rpc()'
|
|
38
|
-
}, {
|
|
39
|
-
title: 'should use the combined entry index.',
|
|
40
|
-
code: "my[a]();"
|
|
41
|
-
}],
|
|
42
|
-
formatResult: function formatResult(code) {
|
|
43
|
-
return code.replace(_path.default.resolve(__dirname, '../../../'), '');
|
|
44
|
-
}
|
|
45
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _alert = _interopRequireDefault(require("./alert"));
|
|
9
|
-
var _default = {
|
|
10
|
-
alert: _alert.default
|
|
11
|
-
};
|
|
12
|
-
exports.default = _default;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|