@dolphinweex/weex-harmony-transform 0.1.11 → 0.1.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dolphinweex/weex-harmony-transform",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "weex harmony adapter",
5
5
  "main": "index.js",
6
6
  "files": [
package/src/adapter.ts CHANGED
@@ -563,6 +563,15 @@ let router = {
563
563
  deleteGlobalAppCache: function (param, callback, failCallback) {
564
564
  weexModule.callNative('router.deleteGlobalAppCache', { 'options': param }, callback, undefined, failCallback)
565
565
  },
566
+ navigateTo: function (param, callback, failCallback) {
567
+ weexModule.callNative('router.navigateTo', { 'options': param }, callback, undefined, failCallback)
568
+ },
569
+ navigateBack: function (param, callback, failCallback) {
570
+ weexModule.callNative('router.navigateBack', { 'options': param }, callback, undefined, failCallback)
571
+ },
572
+ exitMiniApp: function (param, callback, failCallback) {
573
+ weexModule.callNative('router.exitMiniApp', { 'options': param }, callback, undefined, failCallback)
574
+ },
566
575
  }
567
576
  let modal = {
568
577
  name: 'modal',
package/weexTransform.js CHANGED
@@ -4,7 +4,10 @@ const weexExtModules = require('./src/weexExtModules')
4
4
  function isNeedWeexExtProxy(module) {
5
5
  return (weexExtModules.indexOf(module) === -1) ? false : true;
6
6
  }
7
-
7
+ const replaceMap = {
8
+ 'weex-bindingx': '@dolphinweex/weex-bindingx',
9
+ 'weex-vue-render': '@dolphinweex/weex-vue-render'
10
+ }
8
11
  module.exports = function ({ types: t }) {
9
12
  return {
10
13
  name: "weexTransform",
@@ -79,23 +82,24 @@ module.exports = function ({ types: t }) {
79
82
  const arguments = astPath.node.arguments
80
83
  if (arguments && arguments.length > 0 && arguments[0].value) {
81
84
  const oldPath = arguments[0].value;
82
- if (oldPath.startsWith('weex-bindingx')) {
83
- // 构建新的路径节点
84
- const newPathNode = oldPath.replace('weex-bindingx', '@dolphinweex/weex-bindingx')
85
- // 替换原来的路径节点
86
- astPath.node.arguments[0] = {
87
- type:'StringLiteral',
88
- value: newPathNode
89
- };
90
- }
85
+ Object.keys(replaceMap).forEach(key => {
86
+ if (oldPath.startsWith(key)) {
87
+ astPath.node.arguments[0] = {
88
+ type: 'StringLiteral',
89
+ value: oldPath.replace(key, replaceMap[key])
90
+ };
91
+ }
92
+ });
91
93
  }
92
94
  }
93
95
  },
94
96
  ImportDeclaration(path) {
95
- const importPath = path.node.source.value;
96
- if (importPath.startsWith('weex-bindingx')) {
97
- path.node.source.value = importPath.replace('weex-bindingx', '@dolphinweex/weex-bindingx')
98
- }
97
+ const importPath = path.node.source.value;
98
+ Object.keys(replaceMap).forEach(key => {
99
+ if (importPath.startsWith(key)) {
100
+ path.node.source.value = importPath.replace(key, replaceMap[key]);
101
+ }
102
+ });
99
103
  }
100
104
  }
101
105
  };