babel-plugin-transform-taroapi 4.0.1-alpha.0 → 4.0.1

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/LICENSE CHANGED
@@ -154,8 +154,15 @@ See `/LICENSE` for details of the license.
154
154
 
155
155
  ==================
156
156
 
157
+ MIT (stencil-vue2-output-target):
158
+ The following files embed [stencil-vue2-output-target](https://github.com/diondree/stencil-vue2-output-target) MIT:
159
+ `/packages/taro-components-library-vue2/src/vue-component-lib/utils.ts`
160
+ See `/LICENSE` for details of the license.
161
+
162
+ ==================
163
+
157
164
  MIT (weui):
158
- The following files embed [weui](https://github.com/Tencent/weui) MIT:
165
+ The following files embed [stencil-vue2-output-target](https://github.com/Tencent/weui) MIT:
159
166
  `/packages/taro-components/src/components/*.scss`
160
167
  See `/LICENSE.txt` for details of the license.
161
168
 
@@ -165,10 +172,3 @@ Apache-2.0 (intersection-observer):
165
172
  The following files embed [intersection-observer](https://github.com/GoogleChromeLabs/intersection-observer) Apache-2.0:
166
173
  `/packages/taro-api/src/polyfill/intersection-observer.ts`
167
174
  See `/LICENSE.txt` for details of the license.
168
-
169
- ==================
170
-
171
- MIT (babel-plugin-jsx-dom-expressions):
172
- The following files embed [babel-plugin-jsx-dom-expressions](https://github.com/ryansolid/dom-expressions/blob/main/packages/babel-plugin-jsx-dom-expressions) MIT:
173
- `/packages/babel-plugin-transform-solid-jsx/src/*`
174
- See `/LICENSE` for details of the license.
@@ -1,7 +1,7 @@
1
1
  import * as babel from '@babel/core'
2
2
  import * as t from '@babel/types'
3
+ import * as definition from '@tarojs/plugin-platform-h5/dist/definition.json'
3
4
 
4
- import * as definition from '../../taro-platform-h5/dist/definition.json'
5
5
  import plugin from '../src'
6
6
 
7
7
  type ImportType = babel.types.ImportSpecifier | babel.types.ImportDefaultSpecifier | babel.types.ImportNamespaceSpecifier
package/babel.config.json CHANGED
@@ -4,7 +4,8 @@
4
4
  "@babel/preset-env",
5
5
  {
6
6
  "targets": {
7
- "node": "current"
7
+ "ios": "9",
8
+ "android": "4.4"
8
9
  }
9
10
  }
10
11
  ]
package/package.json CHANGED
@@ -1,27 +1,21 @@
1
1
  {
2
2
  "name": "babel-plugin-transform-taroapi",
3
- "version": "4.0.1-alpha.0",
4
- "author": "O2Team",
5
- "license": "MIT",
3
+ "version": "4.0.1",
6
4
  "main": "dist/index.js",
7
- "engines": {
8
- "node": ">= 18"
9
- },
10
5
  "dependencies": {
11
6
  "lodash": "^4.17.21"
12
7
  },
13
8
  "devDependencies": {
14
- "@babel/core": "7.24.4",
15
- "@babel/types": "7.24.0",
16
- "@types/babel__core": "7.20.5"
17
- },
18
- "peerDependencies": {
19
- "@babel/core": "^7.0.0"
9
+ "@babel/core": "^7.14.5",
10
+ "@babel/types": "^7.14.5",
11
+ "babel-jest": "^29.5.0",
12
+ "jest": "^29.3.1",
13
+ "jest-cli": "^29.3.1",
14
+ "ts-jest": "^29.0.5",
15
+ "typescript": "^4.7.4"
20
16
  },
17
+ "license": "MIT",
21
18
  "scripts": {
22
- "prod": "pnpm run build",
23
- "prebuild": "pnpm run clean",
24
- "clean": "rimraf --impl=move-remove ./dist",
25
19
  "build": "tsc",
26
20
  "test": "cross-env NODE_ENV=jest jest",
27
21
  "test:ci": "cross-env NODE_ENV=jest jest --ci -i --coverage --silent",
package/src/index.ts CHANGED
@@ -60,7 +60,7 @@ const plugin = function (babel: typeof BabelCore): BabelCore.PluginObj<IState> {
60
60
  this.apis = apis
61
61
  },
62
62
  visitor: {
63
- ImportDeclaration (ast: BabelCore.NodePath<any>) {
63
+ ImportDeclaration (ast) {
64
64
  if (ast.node.source.value !== this.packageName) return
65
65
 
66
66
  ast.node.specifiers.forEach(node => {
@@ -91,7 +91,7 @@ const plugin = function (babel: typeof BabelCore): BabelCore.PluginObj<IState> {
91
91
  }
92
92
  })
93
93
  },
94
- MemberExpression (ast: BabelCore.NodePath<any>) {
94
+ MemberExpression (ast) {
95
95
  /* 处理Taro.xxx */
96
96
  const isTaro = t.isIdentifier(ast.node.object, { name: taroName })
97
97
  const property = ast.node.property
@@ -110,7 +110,7 @@ const plugin = function (babel: typeof BabelCore): BabelCore.PluginObj<IState> {
110
110
 
111
111
  // 同一api使用多次, 读取变量名
112
112
  if (this.apis.has(propertyName)) {
113
- const parentNode = ast.parent as BabelCore.types.AssignmentExpression
113
+ const parentNode = ast.parent
114
114
  const isAssignment = t.isAssignmentExpression(parentNode) && parentNode.left === ast.node
115
115
 
116
116
  if (!isAssignment) {
@@ -129,7 +129,7 @@ const plugin = function (babel: typeof BabelCore): BabelCore.PluginObj<IState> {
129
129
  needDefault = true
130
130
  }
131
131
  },
132
- CallExpression (ast: BabelCore.NodePath<any>) {
132
+ CallExpression (ast) {
133
133
  if (!ast.scope.hasReference(this.canIUse)) return
134
134
  const callee = ast.node.callee
135
135
  if (t.isMemberExpression(callee) && t.isIdentifier(callee.object, { name: taroName })) {
@@ -188,7 +188,7 @@ const plugin = function (babel: typeof BabelCore): BabelCore.PluginObj<IState> {
188
188
  ast.node.specifiers = namedImports
189
189
  }
190
190
  },
191
- CallExpression (ast: BabelCore.NodePath<any>) {
191
+ CallExpression (ast) {
192
192
  if (!invokedApis.has(that.canIUse)) return
193
193
  const callee = ast.node.callee
194
194
  const { name } = t.identifier(invokedApis.get(that.canIUse)!)