diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 3f09d971a52f..7a6e9a579e6a 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,5 +1,5 @@ blank_issues_enabled: false contact_links: - name: 新建一个新的 Issue - url: https://nervjs.github.io/taro-issue-helper/ + url: https://tls.jd.com/taro-issue-helper about: 请点击 「Open」 按钮打开新链接创建 Issue diff --git a/lerna.json b/lerna.json index e4882ccbe2c8..ae5b152776c4 100644 --- a/lerna.json +++ b/lerna.json @@ -35,6 +35,6 @@ "license": "MIT" } }, - "version": "3.0.6", + "version": "3.0.7", "npmClient": "yarn" } diff --git a/package.json b/package.json index b204ea73d7e5..025c352eda16 100644 --- a/package.json +++ b/package.json @@ -46,18 +46,18 @@ }, "homepage": "https://github.com/NervJS/taro#readme", "devDependencies": { - "@babel/cli": "^7.6.3", - "@babel/core": "^7.6.2", - "@babel/plugin-proposal-class-properties": "^7.5.5", - "@babel/plugin-proposal-decorators": "^7.6.0", - "@babel/plugin-proposal-do-expressions": "^7.8.3", - "@babel/plugin-proposal-object-rest-spread": "^7.10.3", - "@babel/plugin-syntax-dynamic-import": "^7.2.0", - "@babel/plugin-transform-react-jsx": "^7.3.0", - "@babel/plugin-transform-runtime": "^7.10.3", - "@babel/preset-env": "^7.6.2", - "@babel/preset-react": "^7.0.0", - "@babel/preset-typescript": "^7.6.0", + "@babel/cli": "7.10.5", + "@babel/core": "7.11.1", + "@babel/plugin-proposal-class-properties": "7.10.4", + "@babel/plugin-proposal-decorators": "7.10.5", + "@babel/plugin-proposal-do-expressions": "7.10.4", + "@babel/plugin-proposal-object-rest-spread": "7.11.0", + "@babel/plugin-syntax-dynamic-import": "7.8.3", + "@babel/plugin-transform-react-jsx": "7.10.4", + "@babel/plugin-transform-runtime": "7.11.0", + "@babel/preset-env": "7.11.0", + "@babel/preset-react": "7.10.4", + "@babel/preset-typescript": "7.10.4", "@commitlint/cli": "^7.2.1", "@commitlint/config-conventional": "^9.0.1", "@rollup/plugin-replace": "^2.2.0", diff --git a/packages/babel-plugin-transform-taroapi/package.json b/packages/babel-plugin-transform-taroapi/package.json index 29fbf96fee4b..d1b4e221dbfd 100644 --- a/packages/babel-plugin-transform-taroapi/package.json +++ b/packages/babel-plugin-transform-taroapi/package.json @@ -1,6 +1,6 @@ { "name": "babel-plugin-transform-taroapi", - "version": "3.0.6", + "version": "3.0.7", "main": "dist/index.js", "scripts": { "build": "tsc" diff --git a/packages/babel-preset-taro/index.js b/packages/babel-preset-taro/index.js index 9a38fadb4996..50b974db2401 100644 --- a/packages/babel-preset-taro/index.js +++ b/packages/babel-preset-taro/index.js @@ -6,6 +6,8 @@ module.exports = (_, options = {}) => { const plugins = [] const isReact = options.framework === 'react' const isNerv = options.framework === 'nerv' + const isVue = options.framework === 'vue' + const isVue3 = options.framework === 'vue3' const moduleName = options.framework.charAt(0).toUpperCase() + options.framework.slice(1) if (isNerv || isReact) { @@ -20,6 +22,9 @@ module.exports = (_, options = {}) => { if (isNerv || isReact) { config.jsxPragma = moduleName } + if (isVue || isVue3) { + config.allExtensions = true + } presets.push([require('@babel/preset-typescript'), config]) } diff --git a/packages/babel-preset-taro/package.json b/packages/babel-preset-taro/package.json index c0edf04707ab..4fb09be4bdff 100644 --- a/packages/babel-preset-taro/package.json +++ b/packages/babel-preset-taro/package.json @@ -1,6 +1,6 @@ { "name": "babel-preset-taro", - "version": "3.0.6", + "version": "3.0.7", "description": "> TODO: description", "author": "yuche ", "homepage": "https://github.com/nervjs/taro/tree/master/packages/babel-preset-taro#readme", @@ -33,9 +33,9 @@ "@babel/preset-react": "^7.7.4", "@babel/preset-typescript": "^7.8.0", "@babel/runtime": "^7.7.4", - "@tarojs/taro-h5": "3.0.6", + "@tarojs/taro-h5": "3.0.7", "babel-plugin-dynamic-import-node": "^2.3.3", - "babel-plugin-transform-taroapi": "3.0.6", + "babel-plugin-transform-taroapi": "3.0.7", "core-js": "^3.6.3" } } diff --git a/packages/babel-preset-taro/yarn.lock b/packages/babel-preset-taro/yarn.lock index 84e1d502f681..ec8cf614ebf9 100644 --- a/packages/babel-preset-taro/yarn.lock +++ b/packages/babel-preset-taro/yarn.lock @@ -803,13 +803,6 @@ "@babel/helper-plugin-utils" "^7.8.3" "@babel/plugin-transform-typescript" "^7.8.3" -"@babel/runtime@^7.1.2": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.10.4.tgz#a6724f1a6b8d2f6ea5236dbfe58c7d7ea9c5eb99" - integrity sha512-UpTN5yUJr9b4EX2CnGNWIvER7Ab83ibv0pcvvHc4UOdrBI5jb8bj+32cCwPX6xu0mt2daFNjYhoi+X7beH0RSw== - dependencies: - regenerator-runtime "^0.13.4" - "@babel/runtime@^7.7.4": version "7.8.4" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.8.4.tgz#d79f5a2040f7caa24d53e563aad49cbc05581308" @@ -850,43 +843,6 @@ lodash "^4.17.13" to-fast-properties "^2.0.0" -"@tarojs/api@3.0.2": - version "3.0.2" - resolved "https://registry.yarnpkg.com/@tarojs/api/-/api-3.0.2.tgz#655f2fbdeeaedea683f480abf8b47ec2960886e1" - integrity sha512-tbBquuMLhtz05zwoBmPLdYPUQPO8C/p/OdrypK4y6fSlKX2DwCnFUQ1+nZkZgnv5iMsiPnnr0Hh4AhihH/wUHA== - dependencies: - "@tarojs/runtime" "3.0.2" - -"@tarojs/router@3.0.2": - version "3.0.2" - resolved "https://registry.yarnpkg.com/@tarojs/router/-/router-3.0.2.tgz#5b58933b123a415e30630234336af5f88bce4621" - integrity sha512-tx42HZ/h+3AyhQsWGp5JDl/AEKa6jKdNOJAxZFr+dlchve02ePe2juln6p56ES4wHOCPZtopaQmpbZt6QgYijg== - dependencies: - "@tarojs/runtime" "3.0.2" - history "^4.10.1" - universal-router "^8.3.0" - url-parse "^1.4.7" - -"@tarojs/runtime@3.0.2": - version "3.0.2" - resolved "https://registry.yarnpkg.com/@tarojs/runtime/-/runtime-3.0.2.tgz#48036df156eb2c60dfe4bd750944855ed79b8232" - integrity sha512-akW32kGKeRm9bfLTTo3WAeOU/IoWlFFrxw+m7mtjBSm4Q50r/GUMf2jtSyGhIxoWegPMKKRIizPyqf0E5ws0GA== - -"@tarojs/taro-h5@3.0.2": - version "3.0.2" - resolved "https://registry.yarnpkg.com/@tarojs/taro-h5/-/taro-h5-3.0.2.tgz#ce108d6c5c538cda6136a6a66f047db80ed872b1" - integrity sha512-NpHDrG5nKd/3cN/abud/OEpHXRaUWLP8N1ruVLxvB8rPoxqSOs85Vx7p5Opk+oWCqZxrwojcUq4Pr9dXjPhM2w== - dependencies: - "@tarojs/api" "3.0.2" - "@tarojs/router" "3.0.2" - "@tarojs/runtime" "3.0.2" - base64-js "^1.3.0" - jsonp-retry "^1.0.3" - mobile-detect "^1.4.2" - raf "^3.4.1" - unfetch "^4.1.0" - whatwg-fetch "^2.0.4" - ansi-styles@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" @@ -901,15 +857,12 @@ babel-plugin-dynamic-import-node@^2.3.0: dependencies: object.assign "^4.1.0" -babel-plugin-transform-taroapi@3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-taroapi/-/babel-plugin-transform-taroapi-3.0.2.tgz#0511a838f95c4f772a8b3a50f08e26dbef89fb75" - integrity sha512-s2ClNCNvXp0VGsvew9UERetwXWSgOORVc6VZMl8sfBAJI8w3HkQokf3/aYnNJAOEmx0+kB4wCJzD+sryUM0EYQ== - -base64-js@^1.3.0: - version "1.3.1" - resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.3.1.tgz#58ece8cb75dd07e71ed08c736abc5fac4dbf8df1" - integrity sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g== +babel-plugin-dynamic-import-node@^2.3.3: + version "2.3.3" + resolved "https://registry.npm.taobao.org/babel-plugin-dynamic-import-node/download/babel-plugin-dynamic-import-node-2.3.3.tgz#84fda19c976ec5c6defef57f9427b3def66e17a3" + integrity sha1-hP2hnJduxcbe/vV/lCez3vZuF6M= + dependencies: + object.assign "^4.1.0" browserslist@^4.8.3, browserslist@^4.8.5: version "4.8.6" @@ -1020,18 +973,6 @@ has-symbols@^1.0.0: resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.1.tgz#9f5214758a44196c406d9bd76cebf81ec2dd31e8" integrity sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg== -history@^4.10.1: - version "4.10.1" - resolved "https://registry.yarnpkg.com/history/-/history-4.10.1.tgz#33371a65e3a83b267434e2b3f3b1b4c58aad4cf3" - integrity sha512-36nwAD620w12kuzPAsyINPWJqlNbij+hpK1k9XRloDtym8mxzGYl2c17LnV6IAGB2Dmg4tEa7G7DlawS0+qjew== - dependencies: - "@babel/runtime" "^7.1.2" - loose-envify "^1.2.0" - resolve-pathname "^3.0.0" - tiny-invariant "^1.0.2" - tiny-warning "^1.0.0" - value-equal "^1.0.1" - invariant@^2.2.2, invariant@^2.2.4: version "2.2.4" resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" @@ -1061,13 +1002,6 @@ json5@^2.1.0: dependencies: minimist "^1.2.0" -jsonp-retry@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/jsonp-retry/-/jsonp-retry-1.0.3.tgz#9e6b18b02ec767a621dd44b4e99439a8a43a6419" - integrity sha512-/jmE9+shtKP+oIt2AWO9Wx+C27NTGpLCEw4QHOqpoV2X6ta374HE9C+EEdgu8r3iLKgFMx7u5j0mCwxWN8UdlA== - dependencies: - object-assign "^4.1.1" - leven@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/leven/-/leven-3.1.0.tgz#77891de834064cccba82ae7842bb6b14a13ed7f2" @@ -1085,7 +1019,7 @@ lodash@^4.17.13: resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== -loose-envify@^1.0.0, loose-envify@^1.2.0: +loose-envify@^1.0.0: version "1.4.0" resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q== @@ -1097,11 +1031,6 @@ minimist@^1.2.0: resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ= -mobile-detect@^1.4.2: - version "1.4.4" - resolved "https://registry.yarnpkg.com/mobile-detect/-/mobile-detect-1.4.4.tgz#686c74e92d3cc06b09a9b3594b7b981494b137f6" - integrity sha512-vTgEjKjS89C5yHL5qWPpT6BzKuOVqABp+A3Szpbx34pIy3sngxlGaFpgHhfj6fKze1w0QKeOSDbU7SKu7wDvRQ== - ms@^2.1.1: version "2.1.2" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" @@ -1114,11 +1043,6 @@ node-releases@^1.1.47: dependencies: semver "^6.3.0" -object-assign@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" - integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= - object-keys@^1.0.11, object-keys@^1.0.12: version "1.1.1" resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" @@ -1139,33 +1063,11 @@ path-parse@^1.0.6: resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== -path-to-regexp@^3.1.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-3.2.0.tgz#fa7877ecbc495c601907562222453c43cc204a5f" - integrity sha512-jczvQbCUS7XmS7o+y1aEO9OBVFeZBQ1MDSEqmO7xSoPgOPoowY/SxLpZ6Vh97/8qHZOteiCKb7gkG9gA2ZUxJA== - -performance-now@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" - integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns= - private@^0.1.6: version "0.1.8" resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" integrity sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg== -querystringify@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-2.1.1.tgz#60e5a5fd64a7f8bfa4d2ab2ed6fdf4c85bad154e" - integrity sha512-w7fLxIRCRT7U8Qu53jQnJyPkYZIaR4n5151KMfcJlO/A9397Wxb1amJvROTK6TOnp7PfoAmg/qXiNHI+08jRfA== - -raf@^3.4.1: - version "3.4.1" - resolved "https://registry.yarnpkg.com/raf/-/raf-3.4.1.tgz#0742e99a4a6552f445d73e3ee0328af0ff1ede39" - integrity sha512-Sq4CW4QhwOHE8ucn6J34MqtZCeWFP2aQSmrlroYgqAV1PjStIhJXxYuTgUIfkEk7zTLjmIjLmU5q+fbD1NnOJA== - dependencies: - performance-now "^2.1.0" - regenerate-unicode-properties@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-8.1.0.tgz#ef51e0f0ea4ad424b77bf7cb41f3e015c70a3f0e" @@ -1183,11 +1085,6 @@ regenerator-runtime@^0.13.2: resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.3.tgz#7cf6a77d8f5c6f60eb73c5fc1955b2ceb01e6bf5" integrity sha512-naKIZz2GQ8JWh///G7L3X6LaQUAMp2lvb1rvwwsURe/VXwD6VMfr+/1NuNw3ag8v2kY1aQ/go5SNn79O9JU7yw== -regenerator-runtime@^0.13.4: - version "0.13.5" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.5.tgz#d878a1d094b4306d10b9096484b33ebd55e26697" - integrity sha512-ZS5w8CpKFinUzOwW3c83oPeVXoNsrLsaCoLtJvAClH135j/R77RuymhiSErhm2lKcwSCIpmvIWSbDkIfAqKQlA== - regenerator-transform@^0.14.0: version "0.14.1" resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.14.1.tgz#3b2fce4e1ab7732c08f665dfdb314749c7ddd2fb" @@ -1219,16 +1116,6 @@ regjsparser@^0.6.0: dependencies: jsesc "~0.5.0" -requires-port@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" - integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8= - -resolve-pathname@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/resolve-pathname/-/resolve-pathname-3.0.0.tgz#99d02224d3cf263689becbb393bc560313025dcd" - integrity sha512-C7rARubxI8bXFNB/hqcp/4iUeIXJhJZvFPFPiSPRnhU5UPxzMFIl+2E6yY6c4k9giDJAhtV+enfA+G89N6Csng== - resolve@^1.3.2, resolve@^1.8.1: version "1.15.0" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.15.0.tgz#1b7ca96073ebb52e741ffd799f6b39ea462c67f5" @@ -1268,26 +1155,11 @@ supports-color@^5.3.0: dependencies: has-flag "^3.0.0" -tiny-invariant@^1.0.2: - version "1.1.0" - resolved "https://registry.yarnpkg.com/tiny-invariant/-/tiny-invariant-1.1.0.tgz#634c5f8efdc27714b7f386c35e6760991d230875" - integrity sha512-ytxQvrb1cPc9WBEI/HSeYYoGD0kWnGEOR8RY6KomWLBVhqz0RgTwVO9dLrGz7dC+nN9llyI7OKAgRq8Vq4ZBSw== - -tiny-warning@^1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/tiny-warning/-/tiny-warning-1.0.3.tgz#94a30db453df4c643d0fd566060d60a875d84754" - integrity sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA== - to-fast-properties@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" integrity sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4= -unfetch@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/unfetch/-/unfetch-4.1.0.tgz#6ec2dd0de887e58a4dee83a050ded80ffc4137db" - integrity sha512-crP/n3eAPUJxZXM9T80/yv0YhkTEx2K1D3h7D1AJM6fzsWZrxdyRuLN0JH/dkZh1LNH8LxCnBzoPFCPbb2iGpg== - unicode-canonical-property-names-ecmascript@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz#2619800c4c825800efdd8343af7dd9933cbe2818" @@ -1310,28 +1182,3 @@ unicode-property-aliases-ecmascript@^1.0.4: version "1.0.5" resolved "https://registry.yarnpkg.com/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-1.0.5.tgz#a9cc6cc7ce63a0a3023fc99e341b94431d405a57" integrity sha512-L5RAqCfXqAwR3RriF8pM0lU0w4Ryf/GgzONwi6KnL1taJQa7x1TCxdJnILX59WIGOwR57IVxn7Nej0fz1Ny6fw== - -universal-router@^8.3.0: - version "8.3.0" - resolved "https://registry.yarnpkg.com/universal-router/-/universal-router-8.3.0.tgz#533bce135d7b1abf591421c5d2028d54407a34a0" - integrity sha512-cBkihRoHvRQAjdUnDE1GGuuw/TPAIi8z2pEsSmUVAWLeZdgjHzzAb1+0VOO6NvBOvySItOTQikzaGlRxRdJBnA== - dependencies: - path-to-regexp "^3.1.0" - -url-parse@^1.4.7: - version "1.4.7" - resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.4.7.tgz#a8a83535e8c00a316e403a5db4ac1b9b853ae278" - integrity sha512-d3uaVyzDB9tQoSXFvuSUNFibTd9zxd2bkVrDRvF5TmvWWQwqE4lgYJ5m+x1DbecWkw+LK4RNl2CU1hHuOKPVlg== - dependencies: - querystringify "^2.1.1" - requires-port "^1.0.0" - -value-equal@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/value-equal/-/value-equal-1.0.1.tgz#1e0b794c734c5c0cade179c437d356d931a34d6c" - integrity sha512-NOJ6JZCAWr0zlxZt+xqCHNTEKOsrks2HQd4MqhP1qy4z1SkbEP467eNx6TgDKXMvUOb+OENfJCZwM+16n7fRfw== - -whatwg-fetch@^2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz#dde6a5df315f9d39991aa17621853d720b85566f" - integrity sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng== diff --git a/packages/eslint-config-taro/package.json b/packages/eslint-config-taro/package.json index a0c9cc436b2a..6dfc29049494 100644 --- a/packages/eslint-config-taro/package.json +++ b/packages/eslint-config-taro/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-taro", - "version": "3.0.6", + "version": "3.0.7", "description": "Taro specific linting rules for ESLint", "main": "index.js", "files": [ diff --git a/packages/eslint-plugin-taro/package.json b/packages/eslint-plugin-taro/package.json index 369c010f22d5..61bfd6a04502 100644 --- a/packages/eslint-plugin-taro/package.json +++ b/packages/eslint-plugin-taro/package.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-taro", - "version": "3.0.6", + "version": "3.0.7", "description": "Taro specific linting plugin for ESLint", "main": "index.js", "files": [ diff --git a/packages/postcss-plugin-constparse/package.json b/packages/postcss-plugin-constparse/package.json index 69167b12cff1..2f20878a43f3 100644 --- a/packages/postcss-plugin-constparse/package.json +++ b/packages/postcss-plugin-constparse/package.json @@ -1,6 +1,6 @@ { "name": "postcss-plugin-constparse", - "version": "3.0.6", + "version": "3.0.7", "description": "parse constants defined in config", "main": "index.js", "author": "Simba", diff --git a/packages/postcss-pxtransform/package.json b/packages/postcss-pxtransform/package.json index 65eed37fe681..5ec71a2f4e1c 100644 --- a/packages/postcss-pxtransform/package.json +++ b/packages/postcss-pxtransform/package.json @@ -1,6 +1,6 @@ { "name": "postcss-pxtransform", - "version": "3.0.6", + "version": "3.0.7", "description": "PostCSS plugin px 转小程序 rpx及h5 rem 单位", "keywords": [ "postcss", diff --git a/packages/shared/package.json b/packages/shared/package.json index 06a4d888ce84..336c54fc04b4 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/shared", - "version": "3.0.6", + "version": "3.0.7", "description": "> TODO: description", "author": "yuche ", "homepage": "https://github.com/nervjs/taro/tree/master/packages/shared#readme", @@ -16,7 +16,8 @@ "url": "git+https://github.com/NervJS/taro.git" }, "scripts": { - "build": "rollup -c" + "build": "rollup -c", + "dev": "rollup -c -w" }, "bugs": { "url": "https://github.com/NervJS/taro/issues" diff --git a/packages/shared/src/components.ts b/packages/shared/src/components.ts index ed3cbaf9e3c6..c425d07e6ebc 100644 --- a/packages/shared/src/components.ts +++ b/packages/shared/src/components.ts @@ -1,13 +1,11 @@ import { Shortcuts } from './shortcuts' -import { toDashed, hasOwn, toCamelCase } from './utils' -import { isBooleanStringLiteral, isNumber } from './is' -const styles = { +export const styles = { style: `i.${Shortcuts.Style}`, class: `i.${Shortcuts.Class}` } -const events = { +export const events = { bindtap: 'eh' } @@ -19,12 +17,13 @@ const touchEvents = { bindLongTap: '' } -const alipayEvents = { - onTap: 'eh', - onTouchMove: 'eh', - onTouchEnd: 'eh', - onTouchCancel: 'eh', - onLongTap: 'eh' +export const specialEvents = new Set([ + 'htouchmove', + 'vtouchmove' +]) + +export function singleQuote (s: string) { + return `'${s}'` } const View = { @@ -50,12 +49,12 @@ const Map = { longitude: '', latitude: '', scale: '16', - markers: '', + markers: '[]', covers: '', - polyline: '', - circles: '', + polyline: '[]', + circles: '[]', controls: '', - 'include-point': 'false', + 'include-points': '[]', 'show-location': '', polygons: '', subkey: '', @@ -371,16 +370,17 @@ const ScrollView = { bindRefresherRefresh: '', bindRefresherRestore: '', bindRefresherAbort: '', - bindScrolltoUpper: '', - bindScrolltoLower: '', + bindScrollToUpper: '', + bindScrollToLower: '', bindScroll: '', + animation: '', + bindTransitionEnd: '', + bindAnimationStart: '', + bindAnimationIteration: '', + bindAnimationEnd: '', ...touchEvents } -function singleQuote (s: string) { - return `'${s}'` -} - const Swiper = { 'indicator-dots': 'false', 'indicator-color': singleQuote('rgba(0, 0, 0, .3)'), @@ -448,11 +448,6 @@ const Audio = { bindEnded: '' } -const specialEvents = new Set([ - 'htouchmove', - 'vtouchmove' -]) - const Camera = { mode: singleQuote('normal'), 'device-position': singleQuote('back'), @@ -487,9 +482,13 @@ const LivePlayer = { 'sound-mode': singleQuote('speaker'), 'auto-pause-if-navigate': 'true', 'auto-pause-if-open-native': 'true', + 'picture-in-picture-mode': '[]', bindStateChange: '', bindFullScreenChange: '', - bindNetStatus: '' + bindNetStatus: '', + bindAudioVolumeNotify: '', + bindEnterPictureInPicture: '', + bindLeavePictureInPicture: '' } const LivePusher = { @@ -557,6 +556,16 @@ const Video = { 'vslide-gesture': 'false', 'vslide-gesture-in-fullscreen': 'true', 'ad-unit-id': '', + 'poster-for-crawler': '', + 'show-casting-button': 'false', + 'picture-in-picture-mode': '[]', + // picture-in-picture-show-progress 属性先注释掉的原因如下: + // 该属性超过了 wxml 属性的长度限制,实际无法使用且导致编译报错。可等微信官方修复后再放开。 + // 参考1:https://developers.weixin.qq.com/community/develop/doc/000a429beb87f0eac07acc0fc5b400 + // 参考2: https://developers.weixin.qq.com/community/develop/doc/0006883619c48054286a4308258c00?_at=vyxqpllafi + // 'picture-in-picture-show-progress': 'false', + 'enable-auto-rotation': 'false', + 'show-screen-lock-button': 'false', bindPlay: '', bindPause: '', bindEnded: '', @@ -565,11 +574,15 @@ const Video = { bindWaiting: '', bindError: '', bindProgress: '', - bindLoadedMetadata: '' + bindLoadedMetadata: '', + bindControlsToggle: '', + bindEnterPictureInPicture: '', + bindLeavePictureInPicture: '', + bindSeekComplete: '' } const Canvas = { - type: '', + type: singleQuote('2d'), 'canvas-id': '', 'disable-scroll': 'false', bindTouchStart: '', @@ -583,6 +596,8 @@ const Canvas = { const Ad = { 'unit-id': '', 'ad-intervals': '', + 'ad-type': singleQuote('banner'), + 'ad-theme': singleQuote('white'), bindLoad: '', bindError: '', bindClose: '' @@ -646,56 +661,6 @@ const Slot = { name: '' } -interface Components { - [key: string]: Record; -} - -export function createMiniComponents (components: Components, buildType: string) { - const result: Components = Object.create(null) - const isAlipay = buildType === 'alipay' - - for (const key in components) { - if (hasOwn(components, key)) { - const component = components[key] - const compName = toDashed(key) - const newComp: Record = Object.create(null) - for (let prop in component) { - if (hasOwn(component, prop)) { - let propValue = component[prop] - if (prop.startsWith('bind') || specialEvents.has(prop)) { - prop = isAlipay ? prop.replace('bind', 'on') : prop.toLowerCase() - if ((buildType === 'weapp' || buildType === 'qq') && prop === 'bindlongtap') { - prop = 'bindlongpress' - } - propValue = 'eh' - } else if (propValue === '') { - propValue = `i.${toCamelCase(prop)}` - } else if (isBooleanStringLiteral(propValue) || isNumber(+propValue)) { - propValue = `i.${toCamelCase(prop)} === undefined ? ${propValue} : i.${toCamelCase(prop)}` - } else { - propValue = `i.${toCamelCase(prop)} || ${propValue || singleQuote('')}` - } - - newComp[prop] = propValue - } - } - if (compName !== 'block') { - Object.assign(newComp, styles, isAlipay ? alipayEvents : events) - } - - if (compName === 'slot' || compName === 'slot-view') { - result[compName] = { - slot: 'i.name' - } - } else { - result[compName] = newComp - } - } - } - - return result -} - export const internalComponents = { View, Icon, diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index 37363b1ba9e0..9c2c4cfa33c4 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -2,3 +2,4 @@ export * from './is' export { Shortcuts } from './shortcuts' export * from './components' export * from './utils' +export * from './template' diff --git a/packages/shared/src/template.ts b/packages/shared/src/template.ts new file mode 100644 index 000000000000..dd8725fc52d7 --- /dev/null +++ b/packages/shared/src/template.ts @@ -0,0 +1,395 @@ +/** + * 这里我们需要关心的小程序种类有两类: + * 1. 模板递归: + * - 支持:tmpl0 套 tmpl0 + * - 不支持:这就使得我们必须生成多级的模板,tmpl0 套 tmpl1,tmpl1 套 tmpl2…… + * 直到超过阈值 N (N = config.miniapp.baseLevel) tmplN 会套组件 comp,组件 comp 重新再套 tmpl0。 + * 2. 小程序脚本语言(wxs, sjs, etc...): + * - 支持:可以在模板使用函数缩减模板大小或提高性能(存疑),例如判断一个值是不是假值(falsy value)。 + * 将来或许会把数据序列化^1 的操作也放到小程序脚本语言里。 + * - 不支持:使用纯 *xml 语法 + * + * ^1: packages/taro-runtime/src/hydrate.ts +*/ + +import { + internalComponents, + focusComponents, + styles, + events, + specialEvents, + singleQuote +} from './components' +import { Shortcuts } from './shortcuts' +import { isBooleanStringLiteral, isNumber, isFunction } from './is' +import { toCamelCase, toDashed, hasOwn } from './utils' + +interface Component { + nodeName: string; + attributes: Attributes; +} + +interface Components { + [key: string]: Record; +} + +interface ComponentConfig { + includes: Set + exclude: Set + thirdPartyComponents: Map> + includeAll: boolean +} + +export interface IAdapter { + if: string; + else: string; + elseif: string; + for: string; + forItem: string; + forIndex: string; + key: string; + xs?: string, + type: string; +} + +export type Attributes = Record + +const voidElements = new Set([ + 'progress', + 'icon', + 'rich-text', + 'input', + 'textarea', + 'slider', + 'switch', + 'audio', + 'live-player', + 'live-pusher', + 'video' +]) + +const weixinAdapter: IAdapter = { + if: 'wx:if', + else: 'wx:else', + elseif: 'wx:elif', + for: 'wx:for', + forItem: 'wx:for-item', + forIndex: 'wx:for-index', + key: 'wx:key', + xs: 'wxs', + type: 'weapp' +} + +export class BaseTemplate { + protected exportExpr = 'module.exports =' + protected isSupportRecursive: boolean + protected supportXS = false + protected miniComponents: Components + protected modifyCompProps?: (compName: string, target: Record) => Record + protected modifyLoopBody?: (child: string, nodeName: string) => string + protected modifyLoopContainer?: (children: string, nodeName: string) => string + protected modifyTemplateResult?: (res: string, nodeName: string, level: number, children: string) => string + + public Adapter = weixinAdapter + + private buildAttribute (attrs: Attributes, nodeName: string): string { + return Object.keys(attrs) + .map(k => `${k}="${k.startsWith('bind') || k.startsWith('on') ? attrs[k] : `{${this.getAttrValue(attrs[k], k, nodeName)}}`}" `) + .join('') + } + + protected replacePropName (name: string, value: string, _componentName?: string) { + if (value === 'eh') return name.toLowerCase() + return name + } + + protected createMiniComponents (components: Components) { + const result: Components = Object.create(null) + + for (const key in components) { + if (hasOwn(components, key)) { + let component = components[key] + const compName = toDashed(key) + const newComp: Record = Object.create(null) + + if (isFunction(this.modifyCompProps)) { + component = this.modifyCompProps(compName, component) + } + + for (let prop in component) { + if (hasOwn(component, prop)) { + let propValue = component[prop] + if (prop.startsWith('bind') || specialEvents.has(prop)) { + propValue = 'eh' + } else if (propValue === '') { + propValue = `i.${toCamelCase(prop)}` + } else if (isBooleanStringLiteral(propValue) || isNumber(+propValue)) { + propValue = `i.${toCamelCase(prop)}===undefined?${propValue}:i.${toCamelCase(prop)}` + } else { + propValue = `i.${toCamelCase(prop)}||${propValue || singleQuote('')}` + } + + prop = this.replacePropName(prop, propValue, compName) + + newComp[prop] = propValue + } + } + if (compName !== 'block') { + Object.assign(newComp, styles, this.getEvents()) + } + + if (compName === 'swiper-item') { + delete newComp.style + } + + if (compName === 'slot' || compName === 'slot-view') { + result[compName] = { + slot: 'i.name' + } + } else { + result[compName] = newComp + } + } + } + + return result + } + + protected buildBaseTemplate () { + const Adapter = this.Adapter + + return `${this.buildXsTemplate()} +