From 1731295f76e972c52c301c9b05b39a40c35880db Mon Sep 17 00:00:00 2001 From: ZEJIA LIU <53506531+ZEJIA-LIU@users.noreply.github.com> Date: Thu, 25 Jul 2024 22:44:57 +0800 Subject: [PATCH] feat(sync): merge harmony (#16161) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 支持关闭 jsx 样式注入,并提供 css map * chore(release): publish 4.0.0-alpha.24 --tag=alpha * fix(vite): 修复组件模式配置缺失问题 * chore(release): publish 4.0.0-alpha.25 --tag=alpha * feat: update from ets runtime * chore(release): publish 4.0.0-alpha.26 --tag=alpha * feat(harmony): add terser plugin * chore(release): publish 4.0.0-alpha.27 --tag=alpha * fix: 移除废弃插件 * feat(ets): 调整运行时导出 * feat: 更新 capi 版本 runtime * feat(harmony): add cpp style * fix: 修复导出路径 * chore(release): publish 4.0.0-alpha.36 --tag=alpha * fix(harmony): update runtime * fix: 修复cssmodules匹配不到的问题 * feat: comp.js 支持路由重命名 * feat: 去掉console * fix: uid types * fix(harmony): 修复常量替换问题 * fix(harmony): 调整 api 依赖引用 * chore(release): publish 4.0.0-alpha.44 --tag=alpha * fix(harmony): 移除 onpm 不能装载的类型 * fix: 修复 input 事件错误逻辑 * fix: 修复 form 元素移除属性错误 * fix(react): env shake * fix: 修复stickySection没有渲染list-item的问题 * chore(release): publish 4.0.0-beta.119 --tag=beta * fix: 修复list-view问题 * chore(release): publish 4.0.0-beta.120 --tag=beta * fix: 修复sticky-section没有被复用 * chore(release): publish 4.0.0-beta.121 --tag=beta * fix: 修复错误引入taro的问题 * chore(release): publish 4.0.0-beta.122 --tag=beta * chore(release): publish 4.0.0-beta.122 --tag=beta * fix: 修复cssmodule样式不生效 * chore(release): publish 4.0.0-beta.123 --tag=beta * fix: 临时修复 harmony 不能编译 ts 的问题 * chore(release): publish 4.0.0-beta.124 --tag=beta * fix: 兼容找不到页面情况 * fix(harmony): 优化 contextPromise 设置 * fix(harmony): 修复读取配置时缺少常量注入 * chore(release): publish 4.0.0-beta.125 --tag=beta * fix: code * feat(harmony): 修复图片等资源注入引用问题 * chore(release): publish 4.0.0-beta.126 --tag=beta * fix: 修复 readConfig 时引入 babel 导致的问题 * fix: 更新 lint 问题 * chore(release): publish 4.0.0-beta.127 --tag=beta * fix: 修复 readConfig 时引入 babel 导致问题 * chore(release): publish 4.0.0-beta.128 --tag=beta * fix: 修复scroll无法禁止滚动的bug * chore(release): publish 4.0.0-beta.129 --tag=beta * feat: 在style的opacity设置成空字符串里把他设置成1,避免harmony beta2把opacity的默认值设置成0的情况 * fix: 解决合并冲突 * feat: 替换 PLATFORM_TYPE 常量 * chore(release): publish 4.0.3-alpha.5 --tag=alpha * fix: 修复鸿蒙端的pagaName获取不到的问题和ets的类型问题 --------- Co-authored-by: ZakaryCode Co-authored-by: mayintao3 Co-authored-by: zhuminghui2 Co-authored-by: xuanzebin Co-authored-by: liuzejia --- crates/native_binding/package.json | 2 +- npm/darwin-arm64/package.json | 2 +- npm/darwin-x64/package.json | 2 +- npm/linux-x64-gnu/package.json | 2 +- npm/linux-x64-musl/package.json | 2 +- npm/win32-x64-msvc/package.json | 2 +- package.json | 2 +- .../package.json | 2 +- .../package.json | 2 +- .../package.json | 2 +- packages/babel-preset-taro/index.js | 4 +- packages/babel-preset-taro/package.json | 2 +- packages/create-app/package.json | 2 +- packages/css-to-react-native/package.json | 2 +- packages/eslint-config-taro/package.json | 2 +- packages/jest-helper/package.json | 2 +- packages/postcss-html-transform/package.json | 2 +- .../postcss-plugin-constparse/package.json | 2 +- packages/postcss-pxtransform/package.json | 2 +- packages/postcss-unit-transform/package.json | 2 +- packages/rollup-plugin-copy/package.json | 2 +- packages/shared/package.json | 2 +- .../stylelint-config-taro-rn/package.json | 2 +- packages/stylelint-taro-rn/package.json | 2 +- packages/stylelint-taro/package.json | 2 +- packages/taro-api/package.json | 2 +- packages/taro-cli-convertor/package.json | 2 +- packages/taro-cli/package.json | 2 +- .../taro-components-advanced/package.json | 2 +- .../package.json | 2 +- .../package.json | 2 +- .../taro-components-library-vue3/package.json | 2 +- packages/taro-components-react/package.json | 2 +- packages/taro-components-rn/package.json | 2 +- packages/taro-components/package.json | 2 +- packages/taro-extend/package.json | 2 +- packages/taro-framework-react/package.json | 2 +- packages/taro-framework-solid/package.json | 2 +- packages/taro-framework-vue3/package.json | 2 +- packages/taro-h5/package.json | 2 +- packages/taro-helper/package.json | 2 +- packages/taro-loader/package.json | 2 +- packages/taro-platform-alipay/package.json | 2 +- packages/taro-platform-h5/package.json | 2 +- .../taro-platform-harmony-hybrid/package.json | 2 +- packages/taro-platform-harmony/package.json | 2 +- .../src/apis/base/weapp/life-cycle.ts | 2 +- .../src/apis/framework/index.ts | 2 +- .../src/apis/network/downloadFile.ts | 4 +- .../src/apis/network/uploadFile.ts | 4 +- .../src/apis/route/index.ts | 3 +- .../src/apis/ui/background.ts | 2 +- .../src/apis/ui/navigation-bar/index.ts | 2 +- .../src/apis/ui/tab-bar.ts | 3 +- .../src/apis/utils/handler.ts | 3 +- .../src/apis/utils/index.ts | 3 +- .../components-harmony-ets/button.ets | 2 +- .../components-harmony-ets/checkbox.ets | 3 +- .../components-harmony-ets/form.ets | 1 - .../components-harmony-ets/index.ets | 127 +++++------------- .../components-harmony-ets/input.ets | 18 ++- .../components-harmony-ets/label.ets | 3 +- .../components-harmony-ets/listView.ets | 5 +- .../components-harmony-ets/movableArea.ets | 6 +- .../components-harmony-ets/navigationBar.ets | 2 +- .../components-harmony-ets/pageMeta.ets | 2 +- .../components-harmony-ets/pseudo.ets | 2 +- .../components-harmony-ets/radio.ets | 5 +- .../components-harmony-ets/scrollList.ets | 4 +- .../components-harmony-ets/scrollView.ets | 11 +- .../components-harmony-ets/slider.ets | 2 +- .../components-harmony-ets/stickySection.ets | 4 +- .../components-harmony-ets/style.ets | 15 ++- .../components-harmony-ets/swiper.ets | 2 +- .../components-harmony-ets/switch.ets | 2 +- .../components-harmony-ets/text.ets | 4 +- .../components-harmony-ets/utils/helper.ets | 4 +- .../components-harmony-ets/utils/styles.ets | 11 +- .../components-harmony-ets/video.ets | 2 +- .../components-harmony-ets/view.ets | 3 +- .../components-harmony-ets/webView.ets | 2 +- .../src/program/arkTS.ts | 4 + .../src/runtime-ets/bom/URL.ts | 2 + .../src/runtime-ets/bom/document.ts | 3 +- .../src/runtime-ets/bom/getComputedStyle.ts | 3 +- .../src/runtime-ets/bom/history.ts | 1 + .../src/runtime-ets/bom/location.ts | 1 + .../src/runtime-ets/bom/navigator.ts | 22 +-- .../src/runtime-ets/bom/raf.ts | 38 +----- .../src/runtime-ets/bom/window.ts | 9 +- .../src/runtime-ets/constant.ts | 27 ++-- .../src/runtime-ets/current.ts | 26 +++- .../src/runtime-ets/dom/document.ts | 2 +- .../src/runtime-ets/dom/element/canvas.ts | 5 +- .../src/runtime-ets/dom/element/element.ts | 11 +- .../src/runtime-ets/dom/element/form.ts | 6 + .../src/runtime-ets/dom/event-source.ts | 1 + .../src/runtime-ets/dom/eventTarget.ts | 2 +- .../src/runtime-ets/dom/node.ts | 7 +- .../src/runtime-ets/emitter/emitter.ts | 1 + .../src/runtime-ets/env.ts | 1 + .../src/runtime-ets/index.ts | 29 +++- .../src/runtime-ets/interface/index.ts | 6 + .../src/runtime-ets/utils/index.ts | 10 +- .../src/runtime-ets/utils/router.ts | 9 ++ .../src/runtime-framework/react/app.ts | 3 +- .../src/runtime-framework/react/hooks.ts | 2 +- .../runtime-framework/react/native-page.ts | 3 +- .../src/runtime-framework/react/page.ts | 3 +- .../src/runtime-framework/solid/app.ts | 3 +- .../src/runtime-framework/solid/hooks.ts | 2 +- .../src/runtime-framework/solid/page.ts | 3 +- .../solid/reconciler/props.ts | 19 ++- .../taro-platform-harmony/types/runtime.d.ts | 7 + packages/taro-platform-jd/package.json | 2 +- packages/taro-platform-qq/package.json | 2 +- packages/taro-platform-swan/package.json | 2 +- packages/taro-platform-tt/package.json | 2 +- packages/taro-platform-weapp/package.json | 2 +- packages/taro-plugin-html/package.json | 2 +- packages/taro-plugin-http/package.json | 2 +- packages/taro-plugin-inject/package.json | 2 +- packages/taro-plugin-mini-ci/package.json | 2 +- .../taro-plugin-react-devtools/package.json | 2 +- .../taro-plugin-vue-devtools/package.json | 2 +- packages/taro-react/package.json | 2 +- packages/taro-react/src/props.ts | 34 ++--- packages/taro-rn-runner/package.json | 2 +- .../taro-rn-style-transformer/package.json | 2 +- packages/taro-rn-supporter/package.json | 2 +- packages/taro-rn-transformer/package.json | 2 +- packages/taro-rn/package.json | 2 +- packages/taro-router-rn/package.json | 2 +- packages/taro-router/package.json | 2 +- packages/taro-runner-utils/package.json | 2 +- packages/taro-runtime-rn/package.json | 2 +- packages/taro-runtime/package.json | 2 +- packages/taro-runtime/src/bom/URL.ts | 4 +- .../taro-runtime/src/bom/URLSearchParams.ts | 4 +- packages/taro-runtime/src/bom/document.ts | 4 +- .../taro-runtime/src/bom/getComputedStyle.ts | 4 +- packages/taro-runtime/src/bom/history.ts | 4 +- packages/taro-runtime/src/bom/location.ts | 4 +- packages/taro-runtime/src/bom/navigator.ts | 4 +- packages/taro-runtime/src/bom/raf.ts | 6 +- packages/taro-runtime/src/bom/window.ts | 4 +- .../taro-runtime/src/dom-external/index.ts | 4 +- packages/taro-runtime/src/dsl/common.ts | 23 ++-- packages/taro-runtime/src/env.ts | 6 +- packages/taro-runtime/src/next-tick.ts | 4 +- packages/taro-runtime/src/polyfill/index.ts | 6 +- packages/taro-service/package.json | 2 +- packages/taro-transformer-wx/package.json | 2 +- packages/taro-vite-runner/package.json | 27 ++-- .../taro-vite-runner/src/harmony/asset.ts | 42 +++--- .../taro-vite-runner/src/harmony/config.ts | 59 ++++---- packages/taro-vite-runner/src/harmony/page.ts | 2 + .../src/harmony/postcss/constants.ts | 3 +- .../taro-vite-runner/src/harmony/style.ts | 22 +-- .../src/harmony/template/app.ts | 22 +-- .../src/harmony/template/base.ts | 26 ++++ .../src/harmony/template/page.ts | 64 +++++---- .../src/harmony/template/render.ts | 1 + .../src/utils/compiler/harmony.ts | 2 +- packages/taro-webpack5-prebundle/package.json | 2 +- packages/taro-webpack5-runner/package.json | 2 +- packages/taro-with-weapp/package.json | 2 +- packages/taro/package.json | 2 +- packages/taroize/package.json | 2 +- pnpm-lock.yaml | 79 ++++------- 170 files changed, 583 insertions(+), 574 deletions(-) create mode 100644 packages/taro-platform-harmony/src/runtime-ets/bom/URL.ts create mode 100644 packages/taro-platform-harmony/src/runtime-ets/bom/history.ts create mode 100644 packages/taro-platform-harmony/src/runtime-ets/bom/location.ts create mode 100644 packages/taro-platform-harmony/src/runtime-ets/dom/event-source.ts create mode 100644 packages/taro-platform-harmony/src/runtime-ets/emitter/emitter.ts create mode 100644 packages/taro-platform-harmony/src/runtime-ets/env.ts create mode 100644 packages/taro-platform-harmony/src/runtime-ets/utils/router.ts diff --git a/crates/native_binding/package.json b/crates/native_binding/package.json index b50a6dee4130..1b5c1f4de149 100644 --- a/crates/native_binding/package.json +++ b/crates/native_binding/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/binding", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Node binding for taro", "main": "binding.js", "typings": "binding.d.ts", diff --git a/npm/darwin-arm64/package.json b/npm/darwin-arm64/package.json index 33fa7013f7a9..b29aedf49505 100644 --- a/npm/darwin-arm64/package.json +++ b/npm/darwin-arm64/package.json @@ -1,7 +1,7 @@ { "name": "@tarojs/binding-darwin-arm64", "description": "Native binding for taro", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "os": [ "darwin" ], diff --git a/npm/darwin-x64/package.json b/npm/darwin-x64/package.json index a70c10234b78..2ec6a8526f95 100644 --- a/npm/darwin-x64/package.json +++ b/npm/darwin-x64/package.json @@ -1,7 +1,7 @@ { "name": "@tarojs/binding-darwin-x64", "description": "Native binding for taro", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "os": [ "darwin" ], diff --git a/npm/linux-x64-gnu/package.json b/npm/linux-x64-gnu/package.json index 277712b69f16..b346240d11c4 100644 --- a/npm/linux-x64-gnu/package.json +++ b/npm/linux-x64-gnu/package.json @@ -1,7 +1,7 @@ { "name": "@tarojs/binding-linux-x64-gnu", "description": "Native binding for taro", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "os": [ "linux" ], diff --git a/npm/linux-x64-musl/package.json b/npm/linux-x64-musl/package.json index 751b2d58700d..8840a1001901 100644 --- a/npm/linux-x64-musl/package.json +++ b/npm/linux-x64-musl/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/binding-linux-x64-musl", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "os": [ "linux" ], diff --git a/npm/win32-x64-msvc/package.json b/npm/win32-x64-msvc/package.json index a4293a970ecf..8c673ab81c2d 100644 --- a/npm/win32-x64-msvc/package.json +++ b/npm/win32-x64-msvc/package.json @@ -1,7 +1,7 @@ { "name": "@tarojs/binding-win32-x64-msvc", "description": "Native binding for taro", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "os": [ "win32" ], diff --git a/package.json b/package.json index 7f6b715c92dc..b4ee8be8d804 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "taro", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "开放式跨端跨框架开发解决方案", "homepage": "https://github.com/NervJS/taro#readme", "author": "O2Team", diff --git a/packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json b/packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json index 7d17a561bf16..294bdc81102f 100644 --- a/packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json +++ b/packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json @@ -1,6 +1,6 @@ { "name": "babel-plugin-transform-react-jsx-to-rn-stylesheet", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Transform stylesheet selector to style in JSX Elements.", "author": "O2Team", "license": "MIT", diff --git a/packages/babel-plugin-transform-solid-jsx/package.json b/packages/babel-plugin-transform-solid-jsx/package.json index a8fc7178f9cd..761545a6e2e2 100644 --- a/packages/babel-plugin-transform-solid-jsx/package.json +++ b/packages/babel-plugin-transform-solid-jsx/package.json @@ -1,7 +1,7 @@ { "name": "babel-plugin-transform-solid-jsx", "description": "A JSX to DOM plugin that wraps expressions for fine grained change detection", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "license": "MIT", "repository": { "type": "git", diff --git a/packages/babel-plugin-transform-taroapi/package.json b/packages/babel-plugin-transform-taroapi/package.json index 7db17e0b6446..ac507ce0f352 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": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "author": "O2Team", "license": "MIT", "main": "dist/index.js", diff --git a/packages/babel-preset-taro/index.js b/packages/babel-preset-taro/index.js index df4bb80cf160..98c36bb90e6b 100644 --- a/packages/babel-preset-taro/index.js +++ b/packages/babel-preset-taro/index.js @@ -35,8 +35,10 @@ module.exports = (_, options = {}) => { const isSolid = options.framework === 'solid' && !isVite // vite 不需要 vue 的 preset,在内部已经处理了 const isVue3 = options.framework === 'vue3' && !isVite + // TODO:后续改为在 vite harmony 中实现对 ts 的支持 + const isHarmony = process.env.TARO_PLATFORM === 'harmony' // vite 不需要使用 babel 处理 ts,在 esbuild 中处理了 - const isTs = options.ts && !isVite + const isTs = options.ts && (!isVite || isHarmony) const moduleName = options.framework.charAt(0).toUpperCase() + options.framework.slice(1) const presetReactConfig = options.react || {} diff --git a/packages/babel-preset-taro/package.json b/packages/babel-preset-taro/package.json index e0a48e4e7bfe..c5f261f98c5b 100644 --- a/packages/babel-preset-taro/package.json +++ b/packages/babel-preset-taro/package.json @@ -1,6 +1,6 @@ { "name": "babel-preset-taro", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Taro babel preset", "author": "O2Team", "license": "MIT", diff --git a/packages/create-app/package.json b/packages/create-app/package.json index a9320ae6d500..0218c2cd8a4e 100644 --- a/packages/create-app/package.json +++ b/packages/create-app/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/create-app", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "create taro app with one command", "author": "O2Team", "license": "MIT", diff --git a/packages/css-to-react-native/package.json b/packages/css-to-react-native/package.json index 591db5fa85b0..e196392fe5d1 100644 --- a/packages/css-to-react-native/package.json +++ b/packages/css-to-react-native/package.json @@ -1,7 +1,7 @@ { "name": "taro-css-to-react-native", "description": "Convert CSS text to a React Native stylesheet object", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "author": "O2Team", "license": "MIT", "main": "dist/index.js", diff --git a/packages/eslint-config-taro/package.json b/packages/eslint-config-taro/package.json index 6298a8d360e3..f51c6975e277 100644 --- a/packages/eslint-config-taro/package.json +++ b/packages/eslint-config-taro/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-taro", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Taro specific linting rules for ESLint", "author": "O2Team", "license": "MIT", diff --git a/packages/jest-helper/package.json b/packages/jest-helper/package.json index aee502e2153a..009971a9db06 100644 --- a/packages/jest-helper/package.json +++ b/packages/jest-helper/package.json @@ -1,6 +1,6 @@ { "name": "jest-taro-helper", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "jest helper for taro", "private": true, "author": "O2Team", diff --git a/packages/postcss-html-transform/package.json b/packages/postcss-html-transform/package.json index 4e1789da1e76..4da595b627b9 100644 --- a/packages/postcss-html-transform/package.json +++ b/packages/postcss-html-transform/package.json @@ -1,6 +1,6 @@ { "name": "postcss-html-transform", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "transform html tag name selector", "author": "O2Team", "license": "MIT", diff --git a/packages/postcss-plugin-constparse/package.json b/packages/postcss-plugin-constparse/package.json index 5f225b2afcac..7ac601fd33ff 100644 --- a/packages/postcss-plugin-constparse/package.json +++ b/packages/postcss-plugin-constparse/package.json @@ -1,6 +1,6 @@ { "name": "postcss-plugin-constparse", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "parse constants defined in config", "author": "O2Team", "license": "MIT", diff --git a/packages/postcss-pxtransform/package.json b/packages/postcss-pxtransform/package.json index 73bc73aef246..6e13bb6b0d8a 100644 --- a/packages/postcss-pxtransform/package.json +++ b/packages/postcss-pxtransform/package.json @@ -1,6 +1,6 @@ { "name": "postcss-pxtransform", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "PostCSS plugin px 转小程序 rpx及h5 rem 单位", "author": "O2Team", "license": "MIT", diff --git a/packages/postcss-unit-transform/package.json b/packages/postcss-unit-transform/package.json index 90ef70a00039..69c8d8474e23 100644 --- a/packages/postcss-unit-transform/package.json +++ b/packages/postcss-unit-transform/package.json @@ -1,6 +1,6 @@ { "name": "postcss-taro-unit-transform", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "小程序单位转换", "author": "O2Team", "license": "MIT", diff --git a/packages/rollup-plugin-copy/package.json b/packages/rollup-plugin-copy/package.json index 4d231e722646..f31d2e07893b 100644 --- a/packages/rollup-plugin-copy/package.json +++ b/packages/rollup-plugin-copy/package.json @@ -1,6 +1,6 @@ { "name": "rollup-plugin-copy", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "rollup-plugin-copy for taro", "private": true, "author": "O2Team", diff --git a/packages/shared/package.json b/packages/shared/package.json index 77648df30041..dbdaff7cef86 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/shared", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Taro utils internal use.", "author": "O2Team", "license": "MIT", diff --git a/packages/stylelint-config-taro-rn/package.json b/packages/stylelint-config-taro-rn/package.json index 9a9673466b69..21200ecd1b51 100644 --- a/packages/stylelint-config-taro-rn/package.json +++ b/packages/stylelint-config-taro-rn/package.json @@ -1,6 +1,6 @@ { "name": "stylelint-config-taro-rn", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Shareable stylelint config for React Native CSS modules", "author": "O2Team", "license": "MIT", diff --git a/packages/stylelint-taro-rn/package.json b/packages/stylelint-taro-rn/package.json index f9cf022a7d0c..512d777e5025 100644 --- a/packages/stylelint-taro-rn/package.json +++ b/packages/stylelint-taro-rn/package.json @@ -1,6 +1,6 @@ { "name": "stylelint-taro-rn", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "A collection of React Native specific rules for stylelint", "author": "O2Team", "license": "MIT", diff --git a/packages/stylelint-taro/package.json b/packages/stylelint-taro/package.json index 5e910a0d2857..9a1cbf629281 100644 --- a/packages/stylelint-taro/package.json +++ b/packages/stylelint-taro/package.json @@ -1,6 +1,6 @@ { "name": "stylelint-taro", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Taro stylelint 规则集合", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-api/package.json b/packages/taro-api/package.json index 4c3e4b20c130..1aea2020cece 100644 --- a/packages/taro-api/package.json +++ b/packages/taro-api/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/api", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Taro common API", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-cli-convertor/package.json b/packages/taro-cli-convertor/package.json index fb76a505b3ac..371356b982b8 100644 --- a/packages/taro-cli-convertor/package.json +++ b/packages/taro-cli-convertor/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/cli-convertor", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "cli tool for taro-convert", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-cli/package.json b/packages/taro-cli/package.json index 56b42d0f7f02..baa82681e840 100644 --- a/packages/taro-cli/package.json +++ b/packages/taro-cli/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/cli", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "cli tool for taro", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-components-advanced/package.json b/packages/taro-components-advanced/package.json index 7ad8d006788c..fb0dafd8e337 100644 --- a/packages/taro-components-advanced/package.json +++ b/packages/taro-components-advanced/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/components-advanced", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-components-library-react/package.json b/packages/taro-components-library-react/package.json index 51911c618372..cfcee894aba0 100644 --- a/packages/taro-components-library-react/package.json +++ b/packages/taro-components-library-react/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/components-library-react", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Taro 组件库 React 版本库", "private": true, "author": "O2Team", diff --git a/packages/taro-components-library-solid/package.json b/packages/taro-components-library-solid/package.json index c1af55f22a07..d4fdcf92b1e5 100644 --- a/packages/taro-components-library-solid/package.json +++ b/packages/taro-components-library-solid/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/components-library-solid", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Taro 组件库 Solid 版本库", "private": true, "main": "index.js", diff --git a/packages/taro-components-library-vue3/package.json b/packages/taro-components-library-vue3/package.json index 22e1d33571eb..aec35425d006 100644 --- a/packages/taro-components-library-vue3/package.json +++ b/packages/taro-components-library-vue3/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/components-library-vue3", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Taro 组件库 Vue3 版本库", "private": true, "author": "O2Team", diff --git a/packages/taro-components-react/package.json b/packages/taro-components-react/package.json index 22b97f0f6605..354179d5054b 100644 --- a/packages/taro-components-react/package.json +++ b/packages/taro-components-react/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/components-react", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "", "main:h5": "dist/index.js", "main": "dist/index.js", diff --git a/packages/taro-components-rn/package.json b/packages/taro-components-rn/package.json index 5941693ce448..8661f5ba8737 100644 --- a/packages/taro-components-rn/package.json +++ b/packages/taro-components-rn/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/components-rn", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "React Native 基础组件", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-components/package.json b/packages/taro-components/package.json index c67c2be93571..a6e50c003b18 100644 --- a/packages/taro-components/package.json +++ b/packages/taro-components/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/components", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Taro 组件库", "browser": "dist/index.js", "main:h5": "dist/index.js", diff --git a/packages/taro-extend/package.json b/packages/taro-extend/package.json index 9fc6aee8f4da..e85b8f8602be 100644 --- a/packages/taro-extend/package.json +++ b/packages/taro-extend/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/extend", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Taro extend functionality", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-framework-react/package.json b/packages/taro-framework-react/package.json index ec60e38a8a56..adbefb1cd5f9 100644 --- a/packages/taro-framework-react/package.json +++ b/packages/taro-framework-react/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-framework-react", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "React/Preact 框架插件", "author": "O2Team", "homepage": "https://github.com/nervjs/taro", diff --git a/packages/taro-framework-solid/package.json b/packages/taro-framework-solid/package.json index 7ba6dc6aea9c..f8656850982f 100644 --- a/packages/taro-framework-solid/package.json +++ b/packages/taro-framework-solid/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-framework-solid", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Solid 框架插件", "author": "drchan", "homepage": "https://github.com/nervjs/taro", diff --git a/packages/taro-framework-vue3/package.json b/packages/taro-framework-vue3/package.json index 1fdad8534706..c371fbf2be75 100644 --- a/packages/taro-framework-vue3/package.json +++ b/packages/taro-framework-vue3/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-framework-vue3", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Vue3 框架插件", "author": "O2Team", "homepage": "https://github.com/nervjs/taro", diff --git a/packages/taro-h5/package.json b/packages/taro-h5/package.json index 611441adead3..5a85c68ec3f6 100644 --- a/packages/taro-h5/package.json +++ b/packages/taro-h5/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/taro-h5", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Taro h5 framework", "browser": "dist/index.js", "main:h5": "dist/index.esm.js", diff --git a/packages/taro-helper/package.json b/packages/taro-helper/package.json index 690edd054b42..1f497669b606 100644 --- a/packages/taro-helper/package.json +++ b/packages/taro-helper/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/helper", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Taro Helper", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-loader/package.json b/packages/taro-loader/package.json index fd46b9e8421e..5d74728573ee 100644 --- a/packages/taro-loader/package.json +++ b/packages/taro-loader/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/taro-loader", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Taro runner use webpack loader", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-platform-alipay/package.json b/packages/taro-platform-alipay/package.json index 54e0afdac52b..3f66f73c5129 100644 --- a/packages/taro-platform-alipay/package.json +++ b/packages/taro-platform-alipay/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-platform-alipay", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "支付宝小程序平台插件", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-platform-h5/package.json b/packages/taro-platform-h5/package.json index de6a6fa0aef4..05feb6f9c64c 100644 --- a/packages/taro-platform-h5/package.json +++ b/packages/taro-platform-h5/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-platform-h5", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Web 端平台插件", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-platform-harmony-hybrid/package.json b/packages/taro-platform-harmony-hybrid/package.json index 098810eaf6da..30073c421e99 100644 --- a/packages/taro-platform-harmony-hybrid/package.json +++ b/packages/taro-platform-harmony-hybrid/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-platform-harmony-hybrid", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Harmony 端平台插件", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-platform-harmony/package.json b/packages/taro-platform-harmony/package.json index abec8be6851b..29fe7ddd48ff 100644 --- a/packages/taro-platform-harmony/package.json +++ b/packages/taro-platform-harmony/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-platform-harmony-ets", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "OpenHarmony & 鸿蒙系统插件", "author": "O2Team", "homepage": "https://gitee.com/openharmony-sig/taro", diff --git a/packages/taro-platform-harmony/src/apis/base/weapp/life-cycle.ts b/packages/taro-platform-harmony/src/apis/base/weapp/life-cycle.ts index a6fa9a69320a..ecb70a147690 100644 --- a/packages/taro-platform-harmony/src/apis/base/weapp/life-cycle.ts +++ b/packages/taro-platform-harmony/src/apis/base/weapp/life-cycle.ts @@ -1,4 +1,4 @@ -import { eventCenter } from '@tarojs/runtime/dist/runtime.esm' +import { eventCenter } from '@tarojs/runtime' import type Taro from '@tarojs/taro/types' diff --git a/packages/taro-platform-harmony/src/apis/framework/index.ts b/packages/taro-platform-harmony/src/apis/framework/index.ts index fc00af470a24..c364c12af3e5 100644 --- a/packages/taro-platform-harmony/src/apis/framework/index.ts +++ b/packages/taro-platform-harmony/src/apis/framework/index.ts @@ -24,4 +24,4 @@ export { Current, getCurrentInstance } from '@tarojs/runtime' export const requirePlugin = temporarilyNotSupport('requirePlugin') -export { eventCenter, Events, History } from '@tarojs/runtime/dist/runtime.esm' +export { eventCenter, Events, History } from '@tarojs/runtime' diff --git a/packages/taro-platform-harmony/src/apis/network/downloadFile.ts b/packages/taro-platform-harmony/src/apis/network/downloadFile.ts index bf87911a9d65..42d4eee45115 100644 --- a/packages/taro-platform-harmony/src/apis/network/downloadFile.ts +++ b/packages/taro-platform-harmony/src/apis/network/downloadFile.ts @@ -8,10 +8,12 @@ // ❌ DownloadTask.offHeadersReceived 此接口 ohos 不支持 import request from '@ohos.request' -import Taro, { DownloadTask } from '@tarojs/taro' import { callAsyncFail, callAsyncSuccess, validateParams } from '../utils' +import type Taro from '@tarojs/taro/types' +import type { DownloadTask } from '@tarojs/taro/types' + interface IDownloadConfigOHOS { url: string header?: any diff --git a/packages/taro-platform-harmony/src/apis/network/uploadFile.ts b/packages/taro-platform-harmony/src/apis/network/uploadFile.ts index 209abd5a1dc3..9644eb79fd23 100644 --- a/packages/taro-platform-harmony/src/apis/network/uploadFile.ts +++ b/packages/taro-platform-harmony/src/apis/network/uploadFile.ts @@ -9,10 +9,12 @@ import request from '@ohos.request' import { isUndefined } from '@tarojs/shared' -import Taro, { UploadTask } from '@tarojs/taro' import { callAsyncFail, callAsyncSuccess, validateParams } from '../utils' +import type Taro from '@tarojs/taro/types' +import type { UploadTask } from '@tarojs/taro/types' + interface IOHOSFileType { filename?: string name?: string diff --git a/packages/taro-platform-harmony/src/apis/route/index.ts b/packages/taro-platform-harmony/src/apis/route/index.ts index 65eb2e1dc64c..ce85220b655d 100644 --- a/packages/taro-platform-harmony/src/apis/route/index.ts +++ b/packages/taro-platform-harmony/src/apis/route/index.ts @@ -1,6 +1,5 @@ import router from '@ohos.router' -import { window } from '@tarojs/runtime' // eslint-disable-line import/no-duplicates -import { eventCenter } from '@tarojs/runtime/dist/runtime.esm' // eslint-disable-line import/no-duplicates +import { eventCenter, window } from '@tarojs/runtime' import { queryToJson } from '@tarojs/shared' import { callAsyncFail, callAsyncSuccess } from '../utils' diff --git a/packages/taro-platform-harmony/src/apis/ui/background.ts b/packages/taro-platform-harmony/src/apis/ui/background.ts index 8ee18b847fca..c5c76321e34d 100644 --- a/packages/taro-platform-harmony/src/apis/ui/background.ts +++ b/packages/taro-platform-harmony/src/apis/ui/background.ts @@ -1,4 +1,4 @@ -import { eventCenter } from '@tarojs/runtime/dist/runtime.esm' +import { eventCenter } from '@tarojs/runtime' import { temporarilyNotSupport } from '../utils' import { MethodHandler } from '../utils/handler' diff --git a/packages/taro-platform-harmony/src/apis/ui/navigation-bar/index.ts b/packages/taro-platform-harmony/src/apis/ui/navigation-bar/index.ts index e5f0af7af0be..91c21622dd1d 100644 --- a/packages/taro-platform-harmony/src/apis/ui/navigation-bar/index.ts +++ b/packages/taro-platform-harmony/src/apis/ui/navigation-bar/index.ts @@ -1,4 +1,4 @@ -import { eventCenter } from '@tarojs/runtime/dist/runtime.esm' +import { eventCenter } from '@tarojs/runtime' import { MethodHandler } from '../../utils/handler' diff --git a/packages/taro-platform-harmony/src/apis/ui/tab-bar.ts b/packages/taro-platform-harmony/src/apis/ui/tab-bar.ts index e1187c490a6e..2cd467b81ad1 100644 --- a/packages/taro-platform-harmony/src/apis/ui/tab-bar.ts +++ b/packages/taro-platform-harmony/src/apis/ui/tab-bar.ts @@ -1,5 +1,4 @@ -import { Current } from '@tarojs/runtime' // eslint-disable-line import/no-duplicates -import { eventCenter } from '@tarojs/runtime/dist/runtime.esm' // eslint-disable-line import/no-duplicates +import { Current, eventCenter } from '@tarojs/runtime' import { callAsyncFail, callAsyncSuccess } from '../utils' diff --git a/packages/taro-platform-harmony/src/apis/utils/handler.ts b/packages/taro-platform-harmony/src/apis/utils/handler.ts index cc30bcb69fa6..351ba460d306 100644 --- a/packages/taro-platform-harmony/src/apis/utils/handler.ts +++ b/packages/taro-platform-harmony/src/apis/utils/handler.ts @@ -1,10 +1,11 @@ import { isFunction } from '@tarojs/shared' +import type { TFunc } from '@tarojs/runtime' + export interface ICallbackResult { /** 错误信息 */ errMsg: string } -type TFunc = (...args: any[]) => any type TCallback> = (res: T) => Promise | void interface IMethodParam> { diff --git a/packages/taro-platform-harmony/src/apis/utils/index.ts b/packages/taro-platform-harmony/src/apis/utils/index.ts index da2ae670885b..f362b6405402 100644 --- a/packages/taro-platform-harmony/src/apis/utils/index.ts +++ b/packages/taro-platform-harmony/src/apis/utils/index.ts @@ -1,6 +1,5 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl' -import { Current } from '@tarojs/runtime' // eslint-disable-line import/no-duplicates -import { eventCenter } from '@tarojs/runtime/dist/runtime.esm' // eslint-disable-line import/no-duplicates +import { Current, eventCenter } from '@tarojs/runtime' import { ICallbackResult, MethodHandler } from './handler' diff --git a/packages/taro-platform-harmony/src/components/components-harmony-ets/button.ets b/packages/taro-platform-harmony/src/components/components-harmony-ets/button.ets index 089e7cb1fc73..d7f91907d223 100644 --- a/packages/taro-platform-harmony/src/components/components-harmony-ets/button.ets +++ b/packages/taro-platform-harmony/src/components/components-harmony-ets/button.ets @@ -4,7 +4,7 @@ import { BUTTON_THEME_COLOR } from './utils/constant/style' import { TOUCH_EVENT_MAP } from './utils/constant/event' import { shouldBindEvent, getNodeThresholds } from './utils/helper' -import type { TaroAny, TaroEvent, TaroButtonElement, TaroStyleType } from '@tarojs/runtime' +import type { TaroAny, TaroButtonElement, TaroEvent, TaroStyleType } from '@tarojs/runtime' interface ButtonAttrs { disabled?: boolean diff --git a/packages/taro-platform-harmony/src/components/components-harmony-ets/checkbox.ets b/packages/taro-platform-harmony/src/components/components-harmony-ets/checkbox.ets index b2b68fef133b..f3f32396f954 100644 --- a/packages/taro-platform-harmony/src/components/components-harmony-ets/checkbox.ets +++ b/packages/taro-platform-harmony/src/components/components-harmony-ets/checkbox.ets @@ -4,8 +4,7 @@ import commonStyleModify, { rowModify, columnModify } from './style' import { FlexManager } from './utils/flexManager' import { shouldBindEvent, getNodeThresholds } from './utils/helper' -import type { TaroAny, TaroEvent, TaroCheckboxElement, TaroCheckboxGroupElement } from '@tarojs/runtime' -import { isUndefined } from '@tarojs/shared' +import type { TaroAny, TaroCheckboxElement, TaroCheckboxGroupElement, TaroEvent } from '@tarojs/runtime' interface CheckboxOptions { name?: string diff --git a/packages/taro-platform-harmony/src/components/components-harmony-ets/form.ets b/packages/taro-platform-harmony/src/components/components-harmony-ets/form.ets index 45213b432493..4eab90ff8905 100644 --- a/packages/taro-platform-harmony/src/components/components-harmony-ets/form.ets +++ b/packages/taro-platform-harmony/src/components/components-harmony-ets/form.ets @@ -7,7 +7,6 @@ import { FlexManager } from './utils/flexManager' import { shouldBindEvent, getNodeThresholds } from './utils/helper' import type { TaroAny, TaroFormElement } from '@tarojs/runtime' -import { isUndefined } from '@tarojs/shared' @Component export default struct TaroForm { diff --git a/packages/taro-platform-harmony/src/components/components-harmony-ets/index.ets b/packages/taro-platform-harmony/src/components/components-harmony-ets/index.ets index 36fededd7bdf..784a85a22fe0 100644 --- a/packages/taro-platform-harmony/src/components/components-harmony-ets/index.ets +++ b/packages/taro-platform-harmony/src/components/components-harmony-ets/index.ets @@ -1,92 +1,39 @@ -import TaroImage, { getImageMode } from './image' -import TaroText from './text' -import TaroView from './view' -import TaroIcon from './icon' -import TaroForm from './form' -import TaroLabel from './label' -import TaroInput from './input' -import TaroVideo from './video' -import TaroCanvas from './canvas' -import TaroButton from './button' -import TaroPicker from './picker' -import TaroSlider from './slider' -import TaroSwitch from './switch' -import TaroSwiper from './swiper' -import TaroWebView from './webView' -import TaroTextArea from './textArea' -import TaroRichText from './richText' -import TaroProgress from './progress' -import TaroInnerHtml from './innerHtml' -import TaroScrollView from './scrollView' -import TaroMovableArea from './movableArea' -import TaroMovableView from './movableView' -import { TaroRadio, TaroRadioGroup } from './radio' -import { TaroCheckboxGroup, TaroCheckbox } from './checkbox' -import TaroPageMeta from './pageMeta' -import TaroNavigationBar from './navigationBar' +export { default as TaroImage, getImageMode } from './image' +export { default as TaroText } from './text' +export { default as TaroView } from './view' +export { default as TaroIcon } from './icon' +export { default as TaroForm } from './form' +export { default as TaroLabel } from './label' +export { default as TaroInput } from './input' +export { default as TaroVideo } from './video' +export { default as TaroCanvas } from './canvas' +export { default as TaroButton, getButtonColor } from './button' +export { default as TaroPicker } from './picker' +export { default as TaroSlider } from './slider' +export { default as TaroSwitch } from './switch' +export { default as TaroSwiper } from './swiper' +export { default as TaroWebView } from './webView' +export { default as TaroTextArea } from './textArea' +export { default as TaroRichText } from './richText' +export { default as TaroProgress } from './progress' +export { default as TaroInnerHtml } from './innerHtml' +export { default as TaroScrollView } from './scrollView' +export { default as TaroMovableArea } from './movableArea' +export { default as TaroMovableView } from './movableView' +export { TaroRadio, TaroRadioGroup } from './radio' +export { TaroCheckboxGroup, TaroCheckbox } from './checkbox' +export { default as TaroPageMeta, IComponentAttributeUpdateEvents } from './pageMeta' +export { default as TaroNavigationBar } from './navigationBar' -import TaroListView from './listView' -import TaroStickySection from './stickySection' -import TaroScrollList from './scrollList' +export { default as TaroListView } from './listView' +export { default as TaroStickySection } from './stickySection' +export { default as TaroScrollList } from './scrollList' -import commonStyleModify, { rowModify, columnModify, textModify, setNormalTextAttributeIntoInstance } from './style' -import { getButtonColor } from './button' -import { FlexManager } from './utils/flexManager' -import { DynamicCenter } from './utils/DynamicCenter' -import { TOUCH_EVENT_MAP } from './utils/constant/event' -import { BUTTON_THEME_COLOR } from './utils/constant/style' -import { getStyleAttr } from './utils/styles' -import { shouldBindEvent, getNodeThresholds, getNormalAttributes, getFontAttributes } from './utils/helper' - -export { - textModify, - getStyleAttr, - FlexManager, - DynamicCenter, - getButtonColor, - TOUCH_EVENT_MAP, - shouldBindEvent, - getFontAttributes, - commonStyleModify, - rowModify, - columnModify, - getNodeThresholds, - BUTTON_THEME_COLOR, - getNormalAttributes, - setNormalTextAttributeIntoInstance, - getImageMode, -} - -export { - TaroImage, - TaroCanvas, - TaroText, - TaroView, - TaroIcon, - TaroForm, - TaroLabel, - TaroInput, - TaroVideo, - TaroButton, - TaroPicker, - TaroSlider, - TaroSwitch, - TaroSwiper, - TaroWebView, - TaroTextArea, - TaroRichText, - TaroProgress, - TaroInnerHtml, - TaroScrollView, - TaroMovableArea, - TaroMovableView, - TaroRadio, - TaroRadioGroup, - TaroCheckboxGroup, - TaroCheckbox, - TaroPageMeta, - TaroNavigationBar, - TaroListView, - TaroStickySection, - TaroScrollList -} +export { default as commonStyleModify, rowModify, columnModify, textModify, setNormalTextAttributeIntoInstance } from './style' +export { TOUCH_EVENT_MAP } from './utils/constant/event' +export { BUTTON_THEME_COLOR } from './utils/constant/style' +export { DynamicCenter } from './utils/DynamicCenter' +export { FlexManager } from './utils/flexManager' +export { isTagFirstChild } from './utils/helper' +export { getStyleAttr } from './utils/styles' +export { shouldBindEvent, getNodeThresholds, getNormalAttributes, getFontAttributes } from './utils/helper' diff --git a/packages/taro-platform-harmony/src/components/components-harmony-ets/input.ets b/packages/taro-platform-harmony/src/components/components-harmony-ets/input.ets index 5e50ec6ad104..aec14d736ba5 100644 --- a/packages/taro-platform-harmony/src/components/components-harmony-ets/input.ets +++ b/packages/taro-platform-harmony/src/components/components-harmony-ets/input.ets @@ -4,7 +4,7 @@ import commonStyleModify from './style' import { parseStyles, shouldBindEvent, getNodeThresholds, getStyleAttr } from './utils/helper' import { INPUT_TYPE_MAP, INPUT_CONFIRM_MAP } from './utils/constant/style' -import type { TaroStyleType, TaroAny, TaroInputElement, TaroEvent } from '@tarojs/runtime' +import type { TaroAny, TaroEvent, TaroInputElement, TaroStyleType } from '@tarojs/runtime' interface InputAttrs { textAlign?: TextAlign @@ -91,16 +91,20 @@ export default struct TaroInput { .placeholderFont(getPlaceholderFont(this.node)) .enterKeyType(INPUT_CONFIRM_MAP.get(this.node._attrs?.confirmType) || EnterKeyType.Done) .padding(0) // Note: 移出 Input 默认 padding 设置 - .backgroundColor(getStyleAttr(this.node, "backgroundColor"))// + .backgroundColor(getStyleAttr(this.node, "backgroundColor")) .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle)) .styles(this.node?.hmStyle) .attrs(getAttributes(this.node)) .onChange((value: string) => { - const event: TaroEvent = createTaroEvent('input', { detail: { value } }, this.node) - - this.value = value - this.node?.updateFormWidgetValue(value) - eventHandler(event, 'input', this.node) + const event: TaroEvent = createTaroEvent('change', { detail: { value } }, this.node) + eventHandler(event, 'change', this.node) + + if (this.value !== value) { + const event: TaroEvent = createTaroEvent('input', { detail: { value } }, this.node) + this.value = value + this.node?.updateFormWidgetValue(value) + eventHandler(event, 'input', this.node) + } }) .onSubmit(() => { const event: TaroEvent = createTaroEvent('confirm', { detail: { value: this.value } }, this.node) diff --git a/packages/taro-platform-harmony/src/components/components-harmony-ets/label.ets b/packages/taro-platform-harmony/src/components/components-harmony-ets/label.ets index fe139a52ae3f..e2a10eda38de 100644 --- a/packages/taro-platform-harmony/src/components/components-harmony-ets/label.ets +++ b/packages/taro-platform-harmony/src/components/components-harmony-ets/label.ets @@ -6,8 +6,7 @@ import { TOUCH_EVENT_MAP } from './utils/constant/event' import { FlexManager } from './utils/flexManager' import { shouldBindEvent, getNodeThresholds } from './utils/helper' -import type { TaroLabelElement, TaroElement, TaroAny, TaroRadioElement, TaroCheckboxElement } from '@tarojs/runtime' -import { isUndefined } from '@tarojs/shared' +import type { TaroAny, TaroElement, TaroCheckboxElement, TaroLabelElement, TaroRadioElement } from '@tarojs/runtime' function handleTargetChange (id: string) { const taro: TaroAny = Current.taro diff --git a/packages/taro-platform-harmony/src/components/components-harmony-ets/listView.ets b/packages/taro-platform-harmony/src/components/components-harmony-ets/listView.ets index 552a1b9204ed..54ee2c54f015 100644 --- a/packages/taro-platform-harmony/src/components/components-harmony-ets/listView.ets +++ b/packages/taro-platform-harmony/src/components/components-harmony-ets/listView.ets @@ -1,6 +1,6 @@ import commonStyleModify from './style' -import type { TaroViewElement, TaroAny } from '@tarojs/runtime' +import type { TaroAny, TaroViewElement } from '@tarojs/runtime' @Reusable @Component @@ -22,10 +22,11 @@ export default struct TaroListView { build() { ListItem() { - Stack() { + Column() { this.createLazyChildren(this.node, 0) } } .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle)) + .zIndex(0) } } diff --git a/packages/taro-platform-harmony/src/components/components-harmony-ets/movableArea.ets b/packages/taro-platform-harmony/src/components/components-harmony-ets/movableArea.ets index 931da9205bdd..9026e43088e6 100644 --- a/packages/taro-platform-harmony/src/components/components-harmony-ets/movableArea.ets +++ b/packages/taro-platform-harmony/src/components/components-harmony-ets/movableArea.ets @@ -1,9 +1,9 @@ -import type { TaroAny, TaroMovableAreaElement, TaroMovableViewElement } from '@tarojs/runtime' import { isTaroMovableViewElement } from '@tarojs/runtime' import commonStyleModify, { rowModify, columnModify } from './style' import { FlexManager } from './utils/flexManager' -import { isUndefined } from '@tarojs/shared' + +import type { TaroAny, TaroMovableAreaElement } from '@tarojs/runtime' @Component export default struct TaroMovableArea { @@ -123,4 +123,4 @@ function sizeChangeHandle(node: TaroMovableAreaElement, newValue: Area | SizeOpt } } }) -} \ No newline at end of file +} diff --git a/packages/taro-platform-harmony/src/components/components-harmony-ets/navigationBar.ets b/packages/taro-platform-harmony/src/components/components-harmony-ets/navigationBar.ets index e9730000b113..d67e33e0cc3b 100644 --- a/packages/taro-platform-harmony/src/components/components-harmony-ets/navigationBar.ets +++ b/packages/taro-platform-harmony/src/components/components-harmony-ets/navigationBar.ets @@ -1,4 +1,4 @@ -import { eventCenter } from '@tarojs/runtime/dist/runtime.esm' +import { eventCenter } from '@tarojs/runtime' import { isTagFirstChild } from './utils/helper' diff --git a/packages/taro-platform-harmony/src/components/components-harmony-ets/pageMeta.ets b/packages/taro-platform-harmony/src/components/components-harmony-ets/pageMeta.ets index 5fc56f4aff87..ef80a19ca5dc 100644 --- a/packages/taro-platform-harmony/src/components/components-harmony-ets/pageMeta.ets +++ b/packages/taro-platform-harmony/src/components/components-harmony-ets/pageMeta.ets @@ -1,4 +1,4 @@ -import { APP, eventCenter } from '@tarojs/runtime/dist/runtime.esm' +import { APP, eventCenter } from '@tarojs/runtime' import { getCurrentInstance, pageScrollTo } from '@tarojs/taro' import { isTagFirstChild } from './utils/helper' diff --git a/packages/taro-platform-harmony/src/components/components-harmony-ets/pseudo.ets b/packages/taro-platform-harmony/src/components/components-harmony-ets/pseudo.ets index 26dee2d25862..5e3b0c6f3465 100644 --- a/packages/taro-platform-harmony/src/components/components-harmony-ets/pseudo.ets +++ b/packages/taro-platform-harmony/src/components/components-harmony-ets/pseudo.ets @@ -1,7 +1,7 @@ import { getFontAttributes } from './utils/helper' import { pseudoModify } from './style' -import type { TaroViewElement, TaroStyleType, TaroTextStyleType, TaroAny } from '@tarojs/runtime' +import type { TaroAny, TaroStyleType, TaroTextStyleType, TaroViewElement } from '@tarojs/runtime' @Extend(Flex) function flexAttrs (style: TaroStyleType) { diff --git a/packages/taro-platform-harmony/src/components/components-harmony-ets/radio.ets b/packages/taro-platform-harmony/src/components/components-harmony-ets/radio.ets index 543902d16d70..19b86115c1d1 100644 --- a/packages/taro-platform-harmony/src/components/components-harmony-ets/radio.ets +++ b/packages/taro-platform-harmony/src/components/components-harmony-ets/radio.ets @@ -1,12 +1,11 @@ -import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime' +import { AREA_CHANGE_EVENT_NAME, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime' import commonStyleModify, { rowModify, columnModify } from './style' import { TOUCH_EVENT_MAP } from './utils/constant/event' import { FlexManager } from './utils/flexManager' import { shouldBindEvent, getNodeThresholds } from './utils/helper' -import { TaroEvent, TaroAny, HarmonyType, TaroRadioGroupElement, TaroRadioElement } from '@tarojs/runtime' -import { isUndefined } from '@tarojs/shared' +import type { HarmonyType, TaroAny, TaroEvent, TaroRadioElement, TaroRadioGroupElement } from '@tarojs/runtime' interface RadioAttrs { radioStyle?: HarmonyType.RadioStyle diff --git a/packages/taro-platform-harmony/src/components/components-harmony-ets/scrollList.ets b/packages/taro-platform-harmony/src/components/components-harmony-ets/scrollList.ets index 085324731cab..616eba46a967 100644 --- a/packages/taro-platform-harmony/src/components/components-harmony-ets/scrollList.ets +++ b/packages/taro-platform-harmony/src/components/components-harmony-ets/scrollList.ets @@ -4,7 +4,7 @@ import commonStyleModify from './style' import { TOUCH_EVENT_MAP } from './utils/constant/event' import { getNodeThresholds, shouldBindEvent } from './utils/helper' -import type { TaroScrollViewElement, TaroAny, TaroEvent } from '@tarojs/runtime' +import type { TaroAny, TaroEvent, TaroScrollViewElement } from '@tarojs/runtime' interface ScrollViewAttrs { scrollBar: BarState @@ -67,7 +67,7 @@ export default struct TaroScrollList { } } - handleScroll = (scrollOffset: number) => { + handleScroll = (scrollOffset: number) => { handleScrollEvent(this.node, 'scroll', scrollOffset) } diff --git a/packages/taro-platform-harmony/src/components/components-harmony-ets/scrollView.ets b/packages/taro-platform-harmony/src/components/components-harmony-ets/scrollView.ets index 05a24cb4ef5a..bc096a2fc309 100644 --- a/packages/taro-platform-harmony/src/components/components-harmony-ets/scrollView.ets +++ b/packages/taro-platform-harmony/src/components/components-harmony-ets/scrollView.ets @@ -6,7 +6,7 @@ import { FlexManager } from './utils/flexManager' import { TOUCH_EVENT_MAP } from './utils/constant/event' import { getNodeThresholds, getStyleAttr, shouldBindEvent } from './utils/helper' -import type { TaroAny, TaroScrollViewElement, TaroEvent } from '@tarojs/runtime' +import type { TaroAny, TaroEvent, TaroScrollViewElement } from '@tarojs/runtime' interface ScrollViewAttrs { scrollBar: BarState @@ -36,8 +36,13 @@ function getAttributes (node: TaroScrollViewElement): ScrollViewAttrs { function getScrollable (node: TaroScrollViewElement) { const _attrs = node._attrs - - return _attrs.scrollX ? ScrollDirection.Horizontal : ScrollDirection.Vertical + if (_attrs.scrollX) { + return ScrollDirection.Horizontal + } else if (_attrs.scrollY) { + return ScrollDirection.Vertical + } else { + return ScrollDirection.None + } } function handleScrollEvent (node: TaroScrollViewElement, eventName = 'scroll', xOffset?: number, yOffset?: number) { diff --git a/packages/taro-platform-harmony/src/components/components-harmony-ets/slider.ets b/packages/taro-platform-harmony/src/components/components-harmony-ets/slider.ets index 5986875d4710..3259c49575a2 100644 --- a/packages/taro-platform-harmony/src/components/components-harmony-ets/slider.ets +++ b/packages/taro-platform-harmony/src/components/components-harmony-ets/slider.ets @@ -3,7 +3,7 @@ import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBL import commonStyleModify from './style' import { getNodeThresholds, shouldBindEvent } from './utils/helper' -import type { TaroAny, TaroSliderElement, TaroEvent } from '@tarojs/runtime' +import type { TaroAny, TaroEvent, TaroSliderElement } from '@tarojs/runtime' interface SliderAttrs { selectedColor?: ResourceColor diff --git a/packages/taro-platform-harmony/src/components/components-harmony-ets/stickySection.ets b/packages/taro-platform-harmony/src/components/components-harmony-ets/stickySection.ets index 3238ca4edc0b..c0d0ca0846f7 100644 --- a/packages/taro-platform-harmony/src/components/components-harmony-ets/stickySection.ets +++ b/packages/taro-platform-harmony/src/components/components-harmony-ets/stickySection.ets @@ -1,4 +1,5 @@ import commonStyleModify from './style' +import TaroListView from './listView' import type { TaroViewElement, TaroElement, TaroAny } from '@tarojs/runtime' @@ -32,10 +33,9 @@ export default struct TaroStickySection { }) { ForEach(this.node.children, (item: TaroElement) => { if (item.tagName === 'LIST-VIEW') { - this.createLazyChildren(item as TaroViewElement, 0) + TaroListView({ node: item as TaroAny, createLazyChildren: this.createLazyChildren }).reuseId(item._nid.toString()) } }, (item: TaroElement) => `${item._nid}-${item._nodeInfo?.layer || 0}`) - } .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle)) } diff --git a/packages/taro-platform-harmony/src/components/components-harmony-ets/style.ets b/packages/taro-platform-harmony/src/components/components-harmony-ets/style.ets index 5df8a34458f7..8bc9fefda2d7 100644 --- a/packages/taro-platform-harmony/src/components/components-harmony-ets/style.ets +++ b/packages/taro-platform-harmony/src/components/components-harmony-ets/style.ets @@ -1,4 +1,3 @@ -import type { TaroAny, HarmonyStyle, TaroElement, TaroStyleType, TaroTextElement } from '@tarojs/runtime' import { ObjectAssign } from '@tarojs/runtime' import { isUndefined } from '@tarojs/shared' import { computeBackgroundPosition, convertVp2Px } from './utils' @@ -6,6 +5,8 @@ import { getNormalAttributes } from './utils/helper' import { isMaxWidthView } from './utils/styles' import { FlexManager } from './utils/flexManager' +import type { HarmonyStyle, TaroAny, TaroElement, TaroStyleType, TaroTextElement } from '@tarojs/runtime' + class TextStyleModify implements AttributeModifier { initStyle?: TaroStyleType node: TaroTextElement | null = null @@ -81,7 +82,7 @@ class CommonStyleModify implements AttributeModifier { } return this } - + setAnimationStyle (overwriteStyle: Record) { this.overwriteStyle = overwriteStyle if (this.style && this.overwriteStyle && Object.keys(this.overwriteStyle).length) { @@ -248,9 +249,9 @@ export function setNormalAttributeIntoInstance(instance: CommonAttribute, style: instance.key(style.id) } if (!isUndefined(style.display) || !isUndefined(style.visibility)) { - instance.visibility(style.display === 'none' - ? Visibility.None : - !isUndefined(style.visibility) + instance.visibility(style.display === 'none' + ? Visibility.None : + !isUndefined(style.visibility) ? (style.visibility === 'hidden' ? Visibility.Hidden : Visibility.Visible) : Visibility.Visible ) @@ -362,7 +363,7 @@ export function setNormalAttributeIntoInstance(instance: CommonAttribute, style: }) } if (!isUndefined(style.opacity)) { - instance.opacity(style.opacity) + instance.opacity(String(style.opacity) === '' ? 1: style.opacity) } if (!isUndefined(style.overflow)) { instance.clip(style.overflow === 'hidden') @@ -407,4 +408,4 @@ export const rowModify = new RowStyleModify() export const columnModify = new ColumnStyleModify() export const textModify = new TextStyleModify() -export default new CommonStyleModify() \ No newline at end of file +export default new CommonStyleModify() diff --git a/packages/taro-platform-harmony/src/components/components-harmony-ets/swiper.ets b/packages/taro-platform-harmony/src/components/components-harmony-ets/swiper.ets index 97f178b92ba9..30302ec65d34 100644 --- a/packages/taro-platform-harmony/src/components/components-harmony-ets/swiper.ets +++ b/packages/taro-platform-harmony/src/components/components-harmony-ets/swiper.ets @@ -3,7 +3,7 @@ import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBL import commonStyleModify from './style' import { getNodeThresholds, shouldBindEvent } from './utils/helper' -import type { TaroSwiperElement, TaroEvent, TaroAny } from '@tarojs/runtime' +import type { TaroAny, TaroEvent, TaroSwiperElement } from '@tarojs/runtime' interface SwiperAttrs { index?: number diff --git a/packages/taro-platform-harmony/src/components/components-harmony-ets/switch.ets b/packages/taro-platform-harmony/src/components/components-harmony-ets/switch.ets index 895897e81f21..0b0a5f785896 100644 --- a/packages/taro-platform-harmony/src/components/components-harmony-ets/switch.ets +++ b/packages/taro-platform-harmony/src/components/components-harmony-ets/switch.ets @@ -3,7 +3,7 @@ import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBL import commonStyleModify from './style' import { getNodeThresholds, shouldBindEvent } from './utils/helper' -import type { TaroAny, TaroSwitchElement, TaroEvent } from '@tarojs/runtime' +import type { TaroAny, TaroEvent, TaroSwitchElement } from '@tarojs/runtime' interface SwitchAttrs { selectedColor?: ResourceColor diff --git a/packages/taro-platform-harmony/src/components/components-harmony-ets/text.ets b/packages/taro-platform-harmony/src/components/components-harmony-ets/text.ets index 7204fc1dd5f7..3f3899ac47fe 100644 --- a/packages/taro-platform-harmony/src/components/components-harmony-ets/text.ets +++ b/packages/taro-platform-harmony/src/components/components-harmony-ets/text.ets @@ -7,7 +7,7 @@ import { getImageMode } from './image' import { BUTTON_THEME_COLOR } from './utils/constant/style' import { getNodeThresholds, getStyleAttr, shouldBindEvent, getNormalAttributes } from './utils/helper' -import type { TaroButtonElement, TaroElement, TaroTextElement, TaroAny, HarmonyStyle } from '@tarojs/runtime' +import type { HarmonyStyle, TaroAny, TaroButtonElement, TaroElement, TaroTextElement } from '@tarojs/runtime' function getButtonFontSize (node: TaroButtonElement): string | number { const isMini = node._attrs.size === 'mini' @@ -125,4 +125,4 @@ class SpanStyleModify implements AttributeModifier { } } -const spanModify = new SpanStyleModify() \ No newline at end of file +const spanModify = new SpanStyleModify() diff --git a/packages/taro-platform-harmony/src/components/components-harmony-ets/utils/helper.ets b/packages/taro-platform-harmony/src/components/components-harmony-ets/utils/helper.ets index f2b3466fc36c..bb9e58747ac7 100644 --- a/packages/taro-platform-harmony/src/components/components-harmony-ets/utils/helper.ets +++ b/packages/taro-platform-harmony/src/components/components-harmony-ets/utils/helper.ets @@ -1,8 +1,8 @@ -import { VIEW } from '@tarojs/runtime/dist/runtime.esm' +import { VIEW } from '@tarojs/runtime' import { getNormalAttributes, getFontAttributes, getStyleAttr } from './styles' -import type { TaroElement, TaroNode, TaroAny } from '@tarojs/runtime' +import type { TaroAny, TaroElement, TaroNode } from '@tarojs/runtime' export const parseStyles = (styles = ''): Record => { const styleObj: Record = {} diff --git a/packages/taro-platform-harmony/src/components/components-harmony-ets/utils/styles.ets b/packages/taro-platform-harmony/src/components/components-harmony-ets/utils/styles.ets index ea44cf3c42f9..c250bbcd80d3 100644 --- a/packages/taro-platform-harmony/src/components/components-harmony-ets/utils/styles.ets +++ b/packages/taro-platform-harmony/src/components/components-harmony-ets/utils/styles.ets @@ -4,7 +4,7 @@ import { ObjectAssign } from '@tarojs/runtime' import { FlexManager } from './flexManager' import type { StandardProps, TextProps } from '@tarojs/components/types' -import type { TaroAny, TaroElement, TaroStyleType, TaroTextStyleType, HarmonyStyle } from '@tarojs/runtime' +import type { TaroAny, TaroElement, TaroTextStyleType, HarmonyStyle } from '@tarojs/runtime' export function getFontAttributes (node: TaroElement): TaroTextStyleType { let hmStyle = getNormalAttributes(node) @@ -20,7 +20,7 @@ export function getFontAttributes (node: TaroElement): TaroTextStyleType { let WebkitLineClamp = attrs.maxLines || hmStyle.WebkitLineClamp || Infinity if (hmStyle.textOverflow && !isUndefined(hmStyle.textOverflow.overflow)) { switch (hmStyle.textOverflow.overflow) { - case TextOverflow.Clip: + case TextOverflow.Clip: case TextOverflow.Ellipsis: case TextOverflow.None: WebkitLineClamp = WebkitLineClamp || 1; break default: break @@ -90,9 +90,8 @@ export function isMaxWidthView (node: TaroElement) { export function getNormalAttributes (node: TaroElement, initStyle?: HarmonyStyle): HarmonyStyle { if (!node) return {} - + const hmStyle = node.hmStyle - if (!hmStyle) return {} const _nid = node._nid @@ -182,7 +181,7 @@ function getPseudoClass (node: TaroElement): HarmonyStyle | null { function parseNthChild(selector: string): [number, number] | null { const regex = /nth-child\((?:(-?\d*)n\s*)?([+-]?\s*\d+)?\)/; const match = selector.match(regex); - + if (match) { const a = match[1] ? parseInt(match[1]) : 0; const b = match[2] ? parseInt(match[2]) : 0; @@ -202,4 +201,4 @@ export function getStyleAttr(node: TaroElement | null, key: string): TaroAny { return isMaxWidthView(node) && isUndefined(hmStyle.width) ? '100%' : hmStyle.width } return hmStyle[key] -} \ No newline at end of file +} diff --git a/packages/taro-platform-harmony/src/components/components-harmony-ets/video.ets b/packages/taro-platform-harmony/src/components/components-harmony-ets/video.ets index 19d19d8d1ef5..98e0adb165e5 100644 --- a/packages/taro-platform-harmony/src/components/components-harmony-ets/video.ets +++ b/packages/taro-platform-harmony/src/components/components-harmony-ets/video.ets @@ -4,7 +4,7 @@ import commonStyleModify from './style' import { TOUCH_EVENT_MAP } from './utils/constant/event' import { shouldBindEvent, getNodeThresholds } from './utils/helper' -import type { TaroAny, TaroVideoElement, TaroEvent } from '@tarojs/runtime' +import type { TaroAny, TaroEvent, TaroVideoElement } from '@tarojs/runtime' export interface VideoOptions { src?: string | Resource diff --git a/packages/taro-platform-harmony/src/components/components-harmony-ets/view.ets b/packages/taro-platform-harmony/src/components/components-harmony-ets/view.ets index 2c495289e106..408f034098cb 100644 --- a/packages/taro-platform-harmony/src/components/components-harmony-ets/view.ets +++ b/packages/taro-platform-harmony/src/components/components-harmony-ets/view.ets @@ -6,8 +6,7 @@ import { TOUCH_EVENT_MAP } from './utils/constant/event' import { FlexManager } from './utils/flexManager' import { getNodeThresholds, shouldBindEvent } from './utils/helper' -import type { TaroViewElement, TaroAny } from '@tarojs/runtime' -import { isUndefined } from '@tarojs/shared' +import type { TaroAny, TaroViewElement } from '@tarojs/runtime' @Component export default struct TaroView { diff --git a/packages/taro-platform-harmony/src/components/components-harmony-ets/webView.ets b/packages/taro-platform-harmony/src/components/components-harmony-ets/webView.ets index 7204276c3a72..b52fe00edee7 100644 --- a/packages/taro-platform-harmony/src/components/components-harmony-ets/webView.ets +++ b/packages/taro-platform-harmony/src/components/components-harmony-ets/webView.ets @@ -3,7 +3,7 @@ import { AREA_CHANGE_EVENT_NAME, eventHandler, getComponentEventCallback, VISIBL import commonStyleModify from './style' import { shouldBindEvent, getNodeThresholds } from './utils/helper' -import type { TaroAny, TaroWebViewElement, TaroEvent } from '@tarojs/runtime' +import type { TaroAny, TaroEvent, TaroWebViewElement } from '@tarojs/runtime' interface IPageLoad { url: string diff --git a/packages/taro-platform-harmony/src/program/arkTS.ts b/packages/taro-platform-harmony/src/program/arkTS.ts index f6c32c6da8e8..7ee0bbc862a8 100644 --- a/packages/taro-platform-harmony/src/program/arkTS.ts +++ b/packages/taro-platform-harmony/src/program/arkTS.ts @@ -91,6 +91,8 @@ export default class Harmony extends TaroPlatformHarmony { env.forEach(([key, value]) => { this.#defineConstants[`process.env.${key}`] = JSON.stringify(value) }) + + return this.#defineConstants } extensions = ['.js', '.jsx', '.ts', '.tsx', '.cjs', '.mjs', '.mts', '.vue', '.ets', '.d.ts'] @@ -235,6 +237,8 @@ export default class Harmony extends TaroPlatformHarmony { code = apiLoader(code) } if (this.extensions.includes(path.extname(lib))) { + // Note: 移除 onpm 不能装载的类型,新版本会导致 ets-loader 抛出 resolvedFileName 异常 + code = code.replace(/\/{3}\s*\n*/g, '') // Note: 查询 externals 内的依赖,并将它们添加到 externalDeps 中 code = code.replace(/(?:import\s|from\s|require\()['"]([^\\/.][^'"\s]+)['"]\)?/g, (src, p1 = '') => { if (p1.startsWith('node:') || p1.endsWith('.so')) return src diff --git a/packages/taro-platform-harmony/src/runtime-ets/bom/URL.ts b/packages/taro-platform-harmony/src/runtime-ets/bom/URL.ts new file mode 100644 index 000000000000..ec9747f2e3e9 --- /dev/null +++ b/packages/taro-platform-harmony/src/runtime-ets/bom/URL.ts @@ -0,0 +1,2 @@ +export { parseUrl, URL } from '@tarojs/runtime/dist/runtime.esm' +export { URLSearchParams } from '@tarojs/runtime/dist/runtime.esm' diff --git a/packages/taro-platform-harmony/src/runtime-ets/bom/document.ts b/packages/taro-platform-harmony/src/runtime-ets/bom/document.ts index 5869332f7ee2..45b92886fdd3 100644 --- a/packages/taro-platform-harmony/src/runtime-ets/bom/document.ts +++ b/packages/taro-platform-harmony/src/runtime-ets/bom/document.ts @@ -1,5 +1,4 @@ -import { APP, BODY, HEAD, HTML } from '@tarojs/runtime/dist/runtime.esm' - +import { APP, BODY, HEAD, HTML } from '../constant' import { TaroDocument } from '../dom/document' import { window } from './window' diff --git a/packages/taro-platform-harmony/src/runtime-ets/bom/getComputedStyle.ts b/packages/taro-platform-harmony/src/runtime-ets/bom/getComputedStyle.ts index 5380b3cfd11e..f1c0e5ffb375 100644 --- a/packages/taro-platform-harmony/src/runtime-ets/bom/getComputedStyle.ts +++ b/packages/taro-platform-harmony/src/runtime-ets/bom/getComputedStyle.ts @@ -1,5 +1,4 @@ -// import { TaroElement } from '../dom/element/element' - export function getComputedStyle (node: any) { + // @ts-ignore return node._st } diff --git a/packages/taro-platform-harmony/src/runtime-ets/bom/history.ts b/packages/taro-platform-harmony/src/runtime-ets/bom/history.ts new file mode 100644 index 000000000000..f8e4871e5133 --- /dev/null +++ b/packages/taro-platform-harmony/src/runtime-ets/bom/history.ts @@ -0,0 +1 @@ +export { History } from '@tarojs/runtime/dist/runtime.esm' diff --git a/packages/taro-platform-harmony/src/runtime-ets/bom/location.ts b/packages/taro-platform-harmony/src/runtime-ets/bom/location.ts new file mode 100644 index 000000000000..6e5ac1c9a008 --- /dev/null +++ b/packages/taro-platform-harmony/src/runtime-ets/bom/location.ts @@ -0,0 +1 @@ +export { Location } from '@tarojs/runtime/dist/runtime.esm' diff --git a/packages/taro-platform-harmony/src/runtime-ets/bom/navigator.ts b/packages/taro-platform-harmony/src/runtime-ets/bom/navigator.ts index ed5c7c40af08..f5b3417ae826 100644 --- a/packages/taro-platform-harmony/src/runtime-ets/bom/navigator.ts +++ b/packages/taro-platform-harmony/src/runtime-ets/bom/navigator.ts @@ -1,21 +1 @@ -const machine = 'Macintosh' -const arch = 'Intel Mac OS X 10_14_5' -const engine = 'AppleWebKit/534.36 (KHTML, like Gecko) NodeJS/v4.1.0 Chrome/76.0.3809.132 Safari/534.36' - -const msg = '(' + machine + '; ' + arch + ') ' + engine - -export const nav = { - appCodeName: 'Mozilla', - appName: 'Netscape', - appVersion: '5.0 ' + msg, - cookieEnabled: true, - mimeTypes: [], - onLine: true, - platform: 'MacIntel', - plugins: [], - product: 'Taro', - productSub: '20030107', - userAgent: 'Mozilla/5.0 ' + msg, - vendor: 'Joyent', - vendorSub: '' -} +export { navigator } from '@tarojs/runtime/dist/runtime.esm' diff --git a/packages/taro-platform-harmony/src/runtime-ets/bom/raf.ts b/packages/taro-platform-harmony/src/runtime-ets/bom/raf.ts index 646a6f8c6572..1c233ed31e42 100644 --- a/packages/taro-platform-harmony/src/runtime-ets/bom/raf.ts +++ b/packages/taro-platform-harmony/src/runtime-ets/bom/raf.ts @@ -1,37 +1 @@ -// https://github.com/myrne/performance-now -export let now: () => number - -(function () { - let loadTime - if ((typeof performance !== 'undefined' && performance !== null) && performance.now) { - now = () => performance.now() - } else if (Date.now) { - loadTime = Date.now() - now = () => Date.now() - loadTime - } else { - loadTime = new Date().getTime() - now = () => new Date().getTime() - loadTime - } -})() - -let lastTime = 0 - -// https://gist.github.com/paulirish/1579671 -// https://gist.github.com/jalbam/5fe05443270fa6d8136238ec72accbc0 -const _raf = typeof requestAnimationFrame !== 'undefined' && requestAnimationFrame !== null ? requestAnimationFrame : function (callback) { - const _now = now() - const nextTime = Math.max(lastTime + 16, _now) // First time will execute it immediately but barely noticeable and performance is gained. - return setTimeout(function () { callback(lastTime = nextTime) }, nextTime - _now) -} - -const _caf = typeof cancelAnimationFrame !== 'undefined' && cancelAnimationFrame !== null - ? cancelAnimationFrame - : function (seed) { - // fix https://github.com/NervJS/taro/issues/7749 - clearTimeout(seed) - } - -export { - _caf as caf, - _raf as raf -} +export { cancelAnimationFrame, now, requestAnimationFrame } from '@tarojs/runtime/dist/runtime.esm' diff --git a/packages/taro-platform-harmony/src/runtime-ets/bom/window.ts b/packages/taro-platform-harmony/src/runtime-ets/bom/window.ts index 651f2cb51f01..d26c001d60fe 100644 --- a/packages/taro-platform-harmony/src/runtime-ets/bom/window.ts +++ b/packages/taro-platform-harmony/src/runtime-ets/bom/window.ts @@ -1,14 +1,15 @@ import ohosWindow from '@ohos.window' -import { History, Location } from '@tarojs/runtime/dist/runtime.esm' import { getSystemInfoSync } from '@tarojs/taro' import { TaroEventTarget } from '../dom/eventTarget' import { getComputedStyle } from './getComputedStyle' -import { nav } from './navigator' +import { History } from './history' +import { Location } from './location' +import { navigator as nav } from './navigator' import type { TaroDocument } from '../dom/document' -class Window extends TaroEventTarget { +export class Window extends TaroEventTarget { public _doc: TaroDocument public __taroAppConfig: any public __ohos = ohosWindow @@ -44,8 +45,6 @@ class Window extends TaroEventTarget { } } -export { Location, Window } - export const window = new Window() export const location = window.location export const history = window.history diff --git a/packages/taro-platform-harmony/src/runtime-ets/constant.ts b/packages/taro-platform-harmony/src/runtime-ets/constant.ts index d9e056eadbc5..d730f830d3d8 100644 --- a/packages/taro-platform-harmony/src/runtime-ets/constant.ts +++ b/packages/taro-platform-harmony/src/runtime-ets/constant.ts @@ -1,15 +1,22 @@ import { isNumber } from '@tarojs/shared' -export const TYPE = 'type' -export const VALUE = 'value' -export const INPUT = 'input' -export const CHANGE = 'change' -export const TARGET = 'target' -export const CONFIRM = 'confirm' -export const KEY_CODE = 'keyCode' -export const TIME_STAMP = 'timeStamp' -export const CURRENT_TARGET = 'currentTarget' -export const ID = 'id' +export { + A, APP, BEHAVIORS, BODY, + CATCH_VIEW, CATCHMOVE, CHANGE, + CLASS, COMMENT, COMPILE_MODE, + CONFIRM, CONTAINER, CONTEXT_ACTIONS, + CURRENT_TARGET, CUSTOM_WRAPPER, + DATASET, DATE, DOCUMENT_ELEMENT_NAME, + DOCUMENT_FRAGMENT, EVENT_CALLBACK_RESULT, + EXTERNAL_CLASSES, FOCUS, HEAD, + HOOKS_APP_ID, HTML, ID, INPUT, + KEY_CODE, OBJECT, ON_HIDE, ON_LOAD, + ON_READY, ON_SHOW, OPTIONS, PAGE_INIT, + PROPERTY_THRESHOLD, PROPS, PURE_VIEW, ROOT_STR, + SET_DATA, SET_TIMEOUT, STATIC_VIEW, STYLE, + TARGET, TARO_RUNTIME, TIME_STAMP, + TOUCHMOVE, TYPE, UID, VALUE, VIEW +} from '@tarojs/runtime/dist/runtime.esm' export const ATTRIBUTES_CALLBACK_TRIGGER_MAP = { scrollTop: { diff --git a/packages/taro-platform-harmony/src/runtime-ets/current.ts b/packages/taro-platform-harmony/src/runtime-ets/current.ts index 19f5eca7fe66..c93c81fb7188 100644 --- a/packages/taro-platform-harmony/src/runtime-ets/current.ts +++ b/packages/taro-platform-harmony/src/runtime-ets/current.ts @@ -3,16 +3,38 @@ export const context: any = { value: null } -// @ts-nocheck +export const uiContext: any = { + resolver: null, + value: null +} + export const Current: any = { app: null, - uiContext: null, + get uiContext () { + return uiContext.value + }, + set uiContext (e) { + uiContext.resolver(e) + }, router: {}, taro: {}, contextPromise: new Promise(resolve => { context.resolver = resolve return resolve + }).then(e => { + context.value = e + + return e + }), + uiContextPromise: new Promise(resolve => { + uiContext.resolver = resolve + + return resolve + }).then((e) => { + uiContext.value = e + + return e }), createHarmonyElement: null } diff --git a/packages/taro-platform-harmony/src/runtime-ets/dom/document.ts b/packages/taro-platform-harmony/src/runtime-ets/dom/document.ts index a1fca9f287de..941af6f482a1 100644 --- a/packages/taro-platform-harmony/src/runtime-ets/dom/document.ts +++ b/packages/taro-platform-harmony/src/runtime-ets/dom/document.ts @@ -1,10 +1,10 @@ -import { eventSource } from '@tarojs/runtime/dist/runtime.esm' import { isUndefined } from '@tarojs/shared' import { Current } from '../current' import { findChildNodeWithDFS, getPageScrollerOrNode } from '../utils' import { TaroComment } from './comment' import { TaroElement } from './element/element' +import { eventSource } from './event-source' import { NodeType, TaroNode, TaroTextNode } from './node' import type { Window } from '../bom/window' diff --git a/packages/taro-platform-harmony/src/runtime-ets/dom/element/canvas.ts b/packages/taro-platform-harmony/src/runtime-ets/dom/element/canvas.ts index 4b4193e77a75..0a37b7cb4a26 100644 --- a/packages/taro-platform-harmony/src/runtime-ets/dom/element/canvas.ts +++ b/packages/taro-platform-harmony/src/runtime-ets/dom/element/canvas.ts @@ -1,8 +1,9 @@ -import { eventSource, TaroAny, TaroNode } from '@tarojs/runtime' - +import { eventSource } from '../event-source' +import { TaroNode } from '../node' import { TaroElement } from './element' import type { CanvasProps, CanvasTouchEvent } from '@tarojs/components/types' +import type { TaroAny } from '../../interface' export class CanvasRenderingContext2DWXAdapter extends CanvasRenderingContext2D { // constructor(settings?: RenderingContextSetting) { diff --git a/packages/taro-platform-harmony/src/runtime-ets/dom/element/element.ts b/packages/taro-platform-harmony/src/runtime-ets/dom/element/element.ts index 20c86e862a2e..1d595da1255c 100644 --- a/packages/taro-platform-harmony/src/runtime-ets/dom/element/element.ts +++ b/packages/taro-platform-harmony/src/runtime-ets/dom/element/element.ts @@ -1,20 +1,22 @@ // @ts-ignore import { getPageById } from '@tarojs/plugin-framework-react/dist/runtime' -import { eventCenter, eventSource } from '@tarojs/runtime/dist/runtime.esm' import { EMPTY_OBJ, toCamelCase } from '@tarojs/shared' import { ATTRIBUTES_CALLBACK_TRIGGER_MAP, ID } from '../../constant' import { Current } from '../../current' +import { eventCenter } from '../../emitter/emitter' import { findChildNodeWithDFS } from '../../utils' import { initComponentNodeInfo, triggerAttributesCallback } from '../../utils/info' import { bindAnimation } from '../bind' import { ClassList } from '../class-list' -import { type ICSSStyleDeclaration, createCSSStyleDeclaration } from '../cssStyleDeclaration' +import { createCSSStyleDeclaration } from '../cssStyleDeclaration' +import { eventSource } from '../event-source' import { NodeType, TaroNode } from '../node' import StyleSheet, { HarmonyStyle, TaroStyleType } from '../stylesheet' import type { BaseTouchEvent, ITouchEvent, StandardProps } from '@tarojs/components/types' -import type { TaroAny } from '../../utils' +import type { TaroAny } from '../../interface' +import type { ICSSStyleDeclaration } from '../cssStyleDeclaration' type NamedNodeMap = { name: string, value: string }[] @@ -91,7 +93,7 @@ export class TaroElement< } public get id(): string { - return this.getAttribute('id') || this._nid + return this.getAttribute('id') || `${this._nid}` } public set className(value: string) { @@ -338,7 +340,6 @@ export class TaroElement< public setLayer (value: number) { if (!this.parentNode) return // 没有父节点,不需要设置层级关系 - const currentPage = getPageById(this.getAttribute('__fixed')) if (currentPage) { this._page = currentPage diff --git a/packages/taro-platform-harmony/src/runtime-ets/dom/element/form.ts b/packages/taro-platform-harmony/src/runtime-ets/dom/element/form.ts index f514f4e72671..e8cca5acbf1a 100644 --- a/packages/taro-platform-harmony/src/runtime-ets/dom/element/form.ts +++ b/packages/taro-platform-harmony/src/runtime-ets/dom/element/form.ts @@ -56,6 +56,12 @@ class TaroFormWidgetElement extends } } + public removeAttribute(name: string): void { + if (name === 'value') { + this.value = '' + } + } + public get name () { return this._attrs.name || '' } diff --git a/packages/taro-platform-harmony/src/runtime-ets/dom/event-source.ts b/packages/taro-platform-harmony/src/runtime-ets/dom/event-source.ts new file mode 100644 index 000000000000..70265ec01070 --- /dev/null +++ b/packages/taro-platform-harmony/src/runtime-ets/dom/event-source.ts @@ -0,0 +1 @@ +export { eventSource } from '@tarojs/runtime/dist/runtime.esm' diff --git a/packages/taro-platform-harmony/src/runtime-ets/dom/eventTarget.ts b/packages/taro-platform-harmony/src/runtime-ets/dom/eventTarget.ts index b6703d9235d2..0da1e547710b 100644 --- a/packages/taro-platform-harmony/src/runtime-ets/dom/eventTarget.ts +++ b/packages/taro-platform-harmony/src/runtime-ets/dom/eventTarget.ts @@ -1,6 +1,6 @@ -import { Events } from '@tarojs/runtime/dist/runtime.esm' import { isArray } from '@tarojs/shared' +import { Events } from '../emitter/emitter' import { TaroEvent } from './event' import type { EventHandler } from '../interface' diff --git a/packages/taro-platform-harmony/src/runtime-ets/dom/node.ts b/packages/taro-platform-harmony/src/runtime-ets/dom/node.ts index ad0a20dd777c..9544cc40d147 100644 --- a/packages/taro-platform-harmony/src/runtime-ets/dom/node.ts +++ b/packages/taro-platform-harmony/src/runtime-ets/dom/node.ts @@ -1,9 +1,8 @@ -import { eventSource } from '@tarojs/runtime/dist/runtime.esm' - import TaroDataSourceElement from './dataSource' +import { eventSource } from './event-source' import type { StandardProps } from '@tarojs/components/types' -import type { TaroAny } from '../utils' +import type { TaroAny } from '../interface' import type { TaroDocument } from './document' import type { TaroElement } from './element/element' @@ -99,7 +98,7 @@ export class TaroNode extends TaroDataSourceElement { // 提供唯一标识,方便与小程序一致,能根据uid获取到对应的节点 public get uid (): string { - return this._nid + return `${this._nid}` } public get firstChild (): TaroNode | null { diff --git a/packages/taro-platform-harmony/src/runtime-ets/emitter/emitter.ts b/packages/taro-platform-harmony/src/runtime-ets/emitter/emitter.ts new file mode 100644 index 000000000000..dccbe84c52cf --- /dev/null +++ b/packages/taro-platform-harmony/src/runtime-ets/emitter/emitter.ts @@ -0,0 +1 @@ +export { eventCenter, Events, EventsType } from '@tarojs/runtime/dist/runtime.esm' diff --git a/packages/taro-platform-harmony/src/runtime-ets/env.ts b/packages/taro-platform-harmony/src/runtime-ets/env.ts new file mode 100644 index 000000000000..226a548062ea --- /dev/null +++ b/packages/taro-platform-harmony/src/runtime-ets/env.ts @@ -0,0 +1 @@ +export { env } from '@tarojs/runtime/dist/runtime.esm' diff --git a/packages/taro-platform-harmony/src/runtime-ets/index.ts b/packages/taro-platform-harmony/src/runtime-ets/index.ts index 62a137f305e7..1793716f54f2 100644 --- a/packages/taro-platform-harmony/src/runtime-ets/index.ts +++ b/packages/taro-platform-harmony/src/runtime-ets/index.ts @@ -1,18 +1,33 @@ +/* eslint-disable simple-import-sort/exports */ // Current必须放在前面初始化 -// eslint-disable-next-line simple-import-sort/exports export * from './current' +export { hooks } from '@tarojs/shared' +// bom export * from './bom/document' export * from './bom/getComputedStyle' -export { nav as navigator } from './bom/navigator' -export { caf as cancelAnimationFrame, now, raf as requestAnimationFrame } from './bom/raf' +export * from './bom/history' +export * from './bom/location' +export * from './bom/navigator' +export * from './bom/raf' +export * from './bom/URL' export * from './bom/window' +// dom export * from './dom/element' export * from './dom/event' +export * from './dom/event-source' export * from './dom/node' export * from './dom/stylesheet' export * from './dom/cssNesting' -export * from './interface' +// others +export * from './env' +export * from './constant' +export * from './emitter/emitter' export * from './utils' -export * from './utils/info' -export { URL, URLSearchParams, eventSource, Events } from '@tarojs/runtime/dist/runtime.esm' -export { hooks } from '@tarojs/shared' +// typings +export * from './interface' +export { + Instance, PageProps, + ReactPageComponent, ReactPageInstance, ReactAppInstance, + PageLifeCycle, PageInstance, + AppInstance, +} from '@tarojs/runtime/dist/runtime.esm' diff --git a/packages/taro-platform-harmony/src/runtime-ets/interface/index.ts b/packages/taro-platform-harmony/src/runtime-ets/interface/index.ts index c475080bb89d..5454c9f67725 100644 --- a/packages/taro-platform-harmony/src/runtime-ets/interface/index.ts +++ b/packages/taro-platform-harmony/src/runtime-ets/interface/index.ts @@ -1 +1,7 @@ export * from './event' +export { PageConfig, TFunc } from '@tarojs/runtime/dist/runtime.esm' + +export type TaroAny = any +export type TaroFunc = (...args: TaroAny[]) => TaroAny +export type TaroIndent = string | number | boolean | undefined | null +export type TaroObject = Record diff --git a/packages/taro-platform-harmony/src/runtime-ets/utils/index.ts b/packages/taro-platform-harmony/src/runtime-ets/utils/index.ts index aa5b2520d8a0..f689a2b326f9 100644 --- a/packages/taro-platform-harmony/src/runtime-ets/utils/index.ts +++ b/packages/taro-platform-harmony/src/runtime-ets/utils/index.ts @@ -161,9 +161,9 @@ export function findChildNodeWithDFS (node: export function findChildNodeWithDFS (node: TaroElement, selector: string | ((ele: T) => boolean), selectAll): T[] | T | null { const queue = [node] - const nodeList: TaroElement[] = [] + const nodeList: T[] = [] while (queue.length) { - const currentNode = queue.shift() + const currentNode = queue.shift() as T if (currentNode) { if (typeof selector === 'string') { if (selector.startsWith('#')) { @@ -200,7 +200,5 @@ export function findChildNodeWithDFS (node: return null } -export type TaroAny = any -export type TaroFunc = (...args: TaroAny[]) => TaroAny -export type TaroIndent = string | number | boolean | undefined | null -export type TaroObject = Record +export * from './info' +export * from './router' diff --git a/packages/taro-platform-harmony/src/runtime-ets/utils/router.ts b/packages/taro-platform-harmony/src/runtime-ets/utils/router.ts new file mode 100644 index 000000000000..07618227c67a --- /dev/null +++ b/packages/taro-platform-harmony/src/runtime-ets/utils/router.ts @@ -0,0 +1,9 @@ +export { + addLeadingSlash, + getCurrentPage, + getHomePage, + hasBasename, + stripBasename, + stripSuffix, + stripTrailing +} from '@tarojs/runtime/dist/runtime.esm' diff --git a/packages/taro-platform-harmony/src/runtime-framework/react/app.ts b/packages/taro-platform-harmony/src/runtime-framework/react/app.ts index 55949dde02df..bcc42e1c669f 100644 --- a/packages/taro-platform-harmony/src/runtime-framework/react/app.ts +++ b/packages/taro-platform-harmony/src/runtime-framework/react/app.ts @@ -1,5 +1,4 @@ -import { Current, document } from '@tarojs/runtime' // eslint-disable-line import/no-duplicates -import { eventCenter } from '@tarojs/runtime/dist/runtime.esm' // eslint-disable-line import/no-duplicates +import { Current, document, eventCenter } from '@tarojs/runtime' import { setReconciler } from './connect' import { injectPageInstance } from './page' diff --git a/packages/taro-platform-harmony/src/runtime-framework/react/hooks.ts b/packages/taro-platform-harmony/src/runtime-framework/react/hooks.ts index a0dab1346f18..5f41731b2baf 100644 --- a/packages/taro-platform-harmony/src/runtime-framework/react/hooks.ts +++ b/packages/taro-platform-harmony/src/runtime-framework/react/hooks.ts @@ -11,7 +11,7 @@ import type { PageLifeCycle, PageProps, TFunc -} from '@tarojs/runtime/dist/runtime.esm' +} from '@tarojs/runtime' const createTaroHook = (lifecycle: keyof PageLifeCycle | keyof AppInstance) => { return (fn: TFunc) => { diff --git a/packages/taro-platform-harmony/src/runtime-framework/react/native-page.ts b/packages/taro-platform-harmony/src/runtime-framework/react/native-page.ts index 2e54cbf927cc..211391c5105a 100644 --- a/packages/taro-platform-harmony/src/runtime-framework/react/native-page.ts +++ b/packages/taro-platform-harmony/src/runtime-framework/react/native-page.ts @@ -1,5 +1,4 @@ -import { Current, document, requestAnimationFrame, TaroElement, window } from '@tarojs/runtime' // eslint-disable-line import/no-duplicates -import { addLeadingSlash, CONTEXT_ACTIONS, env, eventCenter, TFunc } from '@tarojs/runtime/dist/runtime.esm' // eslint-disable-line import/no-duplicates +import { addLeadingSlash, CONTEXT_ACTIONS, Current, document, env, eventCenter, requestAnimationFrame, TaroElement, TFunc, window } from '@tarojs/runtime' import { ensure, hooks, isUndefined } from '@tarojs/shared' import { ReactMeta as reactMeta } from './app' diff --git a/packages/taro-platform-harmony/src/runtime-framework/react/page.ts b/packages/taro-platform-harmony/src/runtime-framework/react/page.ts index fbd747d700bf..c23c3abe1383 100644 --- a/packages/taro-platform-harmony/src/runtime-framework/react/page.ts +++ b/packages/taro-platform-harmony/src/runtime-framework/react/page.ts @@ -1,5 +1,4 @@ -import { Current, document, requestAnimationFrame, window } from '@tarojs/runtime' // eslint-disable-line import/no-duplicates -import { addLeadingSlash, CONTEXT_ACTIONS, env, eventCenter } from '@tarojs/runtime/dist/runtime.esm' // eslint-disable-line import/no-duplicates +import { addLeadingSlash, CONTEXT_ACTIONS, Current, document, env, eventCenter, requestAnimationFrame, window } from '@tarojs/runtime' import { hooks, isArray, isFunction, isUndefined } from '@tarojs/shared' import { ON_HIDE, ON_LOAD, ON_READY, ON_SHOW, ON_UNLOAD } from './constant' diff --git a/packages/taro-platform-harmony/src/runtime-framework/solid/app.ts b/packages/taro-platform-harmony/src/runtime-framework/solid/app.ts index c4253f75072b..c954663f1a31 100644 --- a/packages/taro-platform-harmony/src/runtime-framework/solid/app.ts +++ b/packages/taro-platform-harmony/src/runtime-framework/solid/app.ts @@ -1,6 +1,5 @@ import { createComponent, h, render } from '@tarojs/plugin-framework-solid/dist/reconciler' -import { Current, document } from '@tarojs/runtime' // eslint-disable-line import/no-duplicates -import { eventCenter } from '@tarojs/runtime/dist/runtime.esm' // eslint-disable-line import/no-duplicates +import { Current, document, eventCenter } from '@tarojs/runtime' import { hooks } from '@tarojs/shared' import { batch, createContext, createRoot, createSignal, For } from 'solid-js' diff --git a/packages/taro-platform-harmony/src/runtime-framework/solid/hooks.ts b/packages/taro-platform-harmony/src/runtime-framework/solid/hooks.ts index daedcadb7c84..c1139454db74 100644 --- a/packages/taro-platform-harmony/src/runtime-framework/solid/hooks.ts +++ b/packages/taro-platform-harmony/src/runtime-framework/solid/hooks.ts @@ -14,7 +14,7 @@ import type { AppInstance, PageLifeCycle, TFunc -} from '@tarojs/runtime/dist/runtime.esm' +} from '@tarojs/runtime' const createTaroHook = (lifecycle: keyof PageLifeCycle | keyof AppInstance) => { return (fn: TFunc) => { diff --git a/packages/taro-platform-harmony/src/runtime-framework/solid/page.ts b/packages/taro-platform-harmony/src/runtime-framework/solid/page.ts index f29d0050b12a..ec18c34157f3 100644 --- a/packages/taro-platform-harmony/src/runtime-framework/solid/page.ts +++ b/packages/taro-platform-harmony/src/runtime-framework/solid/page.ts @@ -1,5 +1,4 @@ -import { Current, document, requestAnimationFrame, window } from '@tarojs/runtime' // eslint-disable-line import/no-duplicates -import { addLeadingSlash, CONTEXT_ACTIONS, env, eventCenter } from '@tarojs/runtime/dist/runtime.esm' // eslint-disable-line import/no-duplicates +import { addLeadingSlash, CONTEXT_ACTIONS, Current, document, env, eventCenter, requestAnimationFrame, window } from '@tarojs/runtime' import { hooks, isArray, isFunction, isUndefined } from '@tarojs/shared' import { ON_HIDE, ON_LOAD, ON_READY, ON_SHOW, ON_UNLOAD } from './constant' diff --git a/packages/taro-platform-harmony/src/runtime-framework/solid/reconciler/props.ts b/packages/taro-platform-harmony/src/runtime-framework/solid/reconciler/props.ts index adf1a1f55a1b..bc57e95d598e 100644 --- a/packages/taro-platform-harmony/src/runtime-framework/solid/reconciler/props.ts +++ b/packages/taro-platform-harmony/src/runtime-framework/solid/reconciler/props.ts @@ -1,11 +1,10 @@ import { convertNumber2PX, FormElement } from '@tarojs/runtime' -import { capitalize, internalComponents, isFunction, isNumber, isObject, isString, toCamelCase } from '@tarojs/shared' +import { capitalize, internalComponents, isFunction, isNumber, isObject, isString, PLATFORM_TYPE, toCamelCase } from '@tarojs/shared' import type { Style, TaroElement } from '@tarojs/runtime' export type Props = Record -const isHarmony = process.env.TARO_PLATFORM === 'harmony' const IS_NON_DIMENSIONAL = /max|aspect|acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i function isEventName (s: string) { @@ -64,16 +63,16 @@ function setEvent (dom: TaroElement, name: string, value: unknown, oldValue?: un const compName = capitalize(toCamelCase(dom.tagName.toLowerCase())) - if (eventName === 'click' && !isHarmony && compName in internalComponents) { + if (eventName === 'click' && process.env.TARO_PLATFORM !== PLATFORM_TYPE.HARMONY && compName in internalComponents) { eventName = 'tap' } if (isFunction(value)) { if (oldValue) { - dom.removeEventListener(eventName, oldValue as any, !isHarmony ? false : undefined) - dom.addEventListener(eventName, value, !isHarmony ? { isCapture, sideEffect: false } : undefined) + dom.removeEventListener(eventName, oldValue as any, process.env.TARO_PLATFORM !== PLATFORM_TYPE.HARMONY ? false : undefined) + dom.addEventListener(eventName, value, process.env.TARO_PLATFORM !== PLATFORM_TYPE.HARMONY ? { isCapture, sideEffect: false } : undefined) } else { - dom.addEventListener(eventName, value, !isHarmony ? isCapture : undefined) + dom.addEventListener(eventName, value, process.env.TARO_PLATFORM !== PLATFORM_TYPE.HARMONY ? isCapture : undefined) } } else { dom.removeEventListener(eventName, oldValue as any) @@ -81,13 +80,13 @@ function setEvent (dom: TaroElement, name: string, value: unknown, oldValue?: un } function setStyle (style: Style, key: string, value: unknown) { - if (key[0] === '-' && !isHarmony) { + if (key[0] === '-' && process.env.TARO_PLATFORM !== PLATFORM_TYPE.HARMONY) { // css variables need not further judgment style.setProperty(key, (value as string).toString()) return } - if (isHarmony && key.startsWith('_')) { + if (process.env.TARO_PLATFORM === PLATFORM_TYPE.HARMONY && key.startsWith('_')) { // harmony样式已处理 style[key] = value == null ? '' : value } else { @@ -145,7 +144,7 @@ export function setProperty (dom: TaroElement, name: string, value: unknown, old for (const i in oldValue) { if (!(value && i in (value as StyleValue))) { // 鸿蒙伪类特殊处理 - if (isHarmony && (i === '::after' || i === '::before')) { + if (process.env.TARO_PLATFORM === PLATFORM_TYPE.HARMONY && (i === '::after' || i === '::before')) { setPseudo(dom, i, null) } else { style[i] = '' @@ -157,7 +156,7 @@ export function setProperty (dom: TaroElement, name: string, value: unknown, old for (const i in value) { if (!oldValue || !isEqual(value[i], (oldValue as StyleValue)[i])) { // 鸿蒙伪类特殊处理 - if (isHarmony && (i === '::after' || i === '::before')) { + if (process.env.TARO_PLATFORM === PLATFORM_TYPE.HARMONY && (i === '::after' || i === '::before')) { setPseudo(dom, i, value[i] as unknown as StyleValue) } else { style[i] = value[i] diff --git a/packages/taro-platform-harmony/types/runtime.d.ts b/packages/taro-platform-harmony/types/runtime.d.ts index fe0b111f3ab5..71445a176442 100644 --- a/packages/taro-platform-harmony/types/runtime.d.ts +++ b/packages/taro-platform-harmony/types/runtime.d.ts @@ -18,4 +18,11 @@ declare module '@tarojs/runtime' { export function findChildNodeWithDFS (node: TaroElement, selector: string | ((ele: T) => boolean), selectAll: boolean): T[] | T | null export const window: any + export type TFunc = (...args: any[]) => any + + export const context: { + resolver: Promise.resolve + value: any + } + export const uiContext: typeof context } diff --git a/packages/taro-platform-jd/package.json b/packages/taro-platform-jd/package.json index 872cc9eb9bf2..60412b252f93 100644 --- a/packages/taro-platform-jd/package.json +++ b/packages/taro-platform-jd/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-platform-jd", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "京东小程序平台插件", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-platform-qq/package.json b/packages/taro-platform-qq/package.json index a367b1a93ded..6e699615df9f 100644 --- a/packages/taro-platform-qq/package.json +++ b/packages/taro-platform-qq/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-platform-qq", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "QQ 小程序平台插件", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-platform-swan/package.json b/packages/taro-platform-swan/package.json index 12bd89e9db07..5e219928a42d 100644 --- a/packages/taro-platform-swan/package.json +++ b/packages/taro-platform-swan/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-platform-swan", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "百度小程序平台插件", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-platform-tt/package.json b/packages/taro-platform-tt/package.json index fb4499559c74..721c9a8b6832 100644 --- a/packages/taro-platform-tt/package.json +++ b/packages/taro-platform-tt/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-platform-tt", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "头条小程序平台插件", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-platform-weapp/package.json b/packages/taro-platform-weapp/package.json index f60488a41b2b..afd0170ca660 100644 --- a/packages/taro-platform-weapp/package.json +++ b/packages/taro-platform-weapp/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-platform-weapp", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "微信小程序平台插件", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-plugin-html/package.json b/packages/taro-plugin-html/package.json index e5c7894e9794..48423c8d494a 100644 --- a/packages/taro-plugin-html/package.json +++ b/packages/taro-plugin-html/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-html", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Taro 小程序端支持使用 HTML 标签的插件", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-plugin-http/package.json b/packages/taro-plugin-http/package.json index 570aa23aaa01..0a3b9a66646b 100644 --- a/packages/taro-plugin-http/package.json +++ b/packages/taro-plugin-http/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-http", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Taro 小程序端支持使用 web 请求 的插件", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-plugin-inject/package.json b/packages/taro-plugin-inject/package.json index 9195be1e6db9..05a4dd6775f0 100644 --- a/packages/taro-plugin-inject/package.json +++ b/packages/taro-plugin-inject/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-inject", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Taro 小程序端平台中间层插件", "author": "O2Team", "homepage": "https://github.com/nervjs/taro", diff --git a/packages/taro-plugin-mini-ci/package.json b/packages/taro-plugin-mini-ci/package.json index af8c4d7faf3b..de44ac9d01b4 100644 --- a/packages/taro-plugin-mini-ci/package.json +++ b/packages/taro-plugin-mini-ci/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-mini-ci", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Taro 小程序端构建后支持CI(持续集成)的插件", "keywords": [ "Taro", diff --git a/packages/taro-plugin-react-devtools/package.json b/packages/taro-plugin-react-devtools/package.json index 3efdac05b566..5c70b17c2f8b 100644 --- a/packages/taro-plugin-react-devtools/package.json +++ b/packages/taro-plugin-react-devtools/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-react-devtools", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Taro 小程序端支持使用 React DevTools 的插件", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-plugin-vue-devtools/package.json b/packages/taro-plugin-vue-devtools/package.json index 4e19596c2955..4f87b81bfed7 100644 --- a/packages/taro-plugin-vue-devtools/package.json +++ b/packages/taro-plugin-vue-devtools/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-vue-devtools", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Taro 小程序端支持使用 Vue DevTools 的插件", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-react/package.json b/packages/taro-react/package.json index 54be74df61ff..b6f58e50de03 100644 --- a/packages/taro-react/package.json +++ b/packages/taro-react/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/react", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "like react-dom, but for mini apps.", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-react/src/props.ts b/packages/taro-react/src/props.ts index 9d13c6950c36..4c37046ea7e3 100644 --- a/packages/taro-react/src/props.ts +++ b/packages/taro-react/src/props.ts @@ -1,11 +1,12 @@ -import { type Style, type TaroElement, convertNumber2PX, FormElement } from '@tarojs/runtime' -import { capitalize, internalComponents, isFunction, isNumber, isObject, isString, toCamelCase } from '@tarojs/shared' +import { convertNumber2PX, FormElement } from '@tarojs/runtime' +import { capitalize, internalComponents, isFunction, isNumber, isObject, isString, PLATFORM_TYPE, toCamelCase } from '@tarojs/shared' + +import type { Style, TaroElement } from '@tarojs/runtime' // 拓展TaroElement的属性 export type Props = Record -const isHarmony = process.env.TARO_PLATFORM === 'harmony' const IS_NON_DIMENSIONAL = /max|aspect|acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i function isEventName (s: string) { @@ -59,7 +60,7 @@ export function updatePropsByPayload (dom: TaroElement, oldProps: Props, updateP const key = updatePayload[i] const newProp = updatePayload[i + 1] const oldProp = oldProps[key] - if (isHarmony) { + if (process.env.TARO_PLATFORM === PLATFORM_TYPE.HARMONY) { if (key === '__fixed') { // hack: __fixed最先识别 fixedHandler = () => setProperty(dom, key, newProp, oldProp) @@ -75,7 +76,7 @@ export function updatePropsByPayload (dom: TaroElement, oldProps: Props, updateP setProperty(dom, key, newProp, oldProp) } } - if (isHarmony) { + if (process.env.TARO_PLATFORM === PLATFORM_TYPE.HARMONY) { fixedHandler && fixedHandler() for (let i = 0; i < handlers.length; i++) { handlers[i]() @@ -120,16 +121,16 @@ function setEvent (dom: TaroElement, name: string, value: unknown, oldValue?: un const compName = capitalize(toCamelCase(dom.tagName.toLowerCase())) - if (eventName === 'click' && !isHarmony && compName in internalComponents) { + if (eventName === 'click' && process.env.TARO_PLATFORM !== PLATFORM_TYPE.HARMONY && compName in internalComponents) { eventName = 'tap' } if (isFunction(value)) { if (oldValue) { - dom.removeEventListener(eventName, oldValue as any, !isHarmony ? false : undefined) - dom.addEventListener(eventName, value, !isHarmony ? { isCapture, sideEffect: false } : undefined) + dom.removeEventListener(eventName, oldValue as any, process.env.TARO_PLATFORM !== PLATFORM_TYPE.HARMONY ? false : undefined) + dom.addEventListener(eventName, value, process.env.TARO_PLATFORM !== PLATFORM_TYPE.HARMONY ? { isCapture, sideEffect: false } : undefined) } else { - dom.addEventListener(eventName, value, !isHarmony ? isCapture : undefined) + dom.addEventListener(eventName, value, process.env.TARO_PLATFORM !== PLATFORM_TYPE.HARMONY ? isCapture : undefined) } } else { dom.removeEventListener(eventName, oldValue as any) @@ -137,7 +138,7 @@ function setEvent (dom: TaroElement, name: string, value: unknown, oldValue?: un } function setStyle (style: Style, key: string, value: unknown) { - if (key[0] === '-' && !isHarmony) { + if (key[0] === '-' && process.env.TARO_PLATFORM !== PLATFORM_TYPE.HARMONY) { // css variables need not further judgment style.setProperty(key, (value as string).toString()) return @@ -145,7 +146,7 @@ function setStyle (style: Style, key: string, value: unknown) { style[key] = isNumber(value) && IS_NON_DIMENSIONAL.test(key) === false - ? (isHarmony ? value + 'px' : convertNumber2PX(value)) + ? (process.env.TARO_PLATFORM === PLATFORM_TYPE.HARMONY ? value + 'px' : convertNumber2PX(value)) : value === null ? '' : value @@ -164,7 +165,7 @@ function setHarmonyStyle(dom: TaroElement, value: unknown, oldValue?: unknown) { for (const i in oldValue) { if (!(value && i in (value as StyleValue))) { // 鸿蒙伪类特殊处理 - if (isHarmony) { + if (process.env.TARO_PLATFORM === PLATFORM_TYPE.HARMONY) { if (i === '::after' || i === '::before') { setPseudo(dom, i, null) } else if (['::first-child', '::last-child', '::empty'].includes(i) || `${i}`.indexOf('::nth-child') === 0) { @@ -190,7 +191,7 @@ function setHarmonyStyle(dom: TaroElement, value: unknown, oldValue?: unknown) { for (const i in value) { if (!oldValue || !isEqual(value[i], (oldValue as StyleValue)[i])) { // 鸿蒙伪类特殊处理 - if (isHarmony) { + if (process.env.TARO_PLATFORM === PLATFORM_TYPE.HARMONY) { if (i === '::after' || i === '::before') { setPseudo(dom, i, value[i] as unknown as StyleValue) } else if (['::first-child', '::last-child', '::empty'].includes(i) || i.startsWith('::nth-child')) { @@ -227,6 +228,9 @@ function setProperty (dom: TaroElement, name: string, value: unknown, oldValue?: ) { // skip } else if (name === 'style') { + if (/harmony.*cpp/.test(process.env.TARO_ENV || '')) { + return dom.setAttribute('_style4cpp', value) + } const style = dom.style if (isString(value)) { style.cssText = value @@ -240,7 +244,7 @@ function setProperty (dom: TaroElement, name: string, value: unknown, oldValue?: for (const i in oldValue) { if (!(value && i in (value as StyleValue))) { // Harmony特殊处理 - if (isHarmony && i === 'position' && oldValue[i] === 'fixed') { + if (process.env.TARO_PLATFORM === PLATFORM_TYPE.HARMONY && i === 'position' && oldValue[i] === 'fixed') { // @ts-ignore dom.setLayer(0) } @@ -253,7 +257,7 @@ function setProperty (dom: TaroElement, name: string, value: unknown, oldValue?: for (const i in value) { if (!oldValue || !isEqual(value[i], (oldValue as StyleValue)[i])) { // Harmony特殊处理 - if (isHarmony && i === 'position') { + if (process.env.TARO_PLATFORM === PLATFORM_TYPE.HARMONY && i === 'position') { if (value[i] === 'fixed' || (value[i] !== 'fixed' && oldValue?.[i])) { // @ts-ignore dom.setLayer(value[i] === 'fixed' ? 1 : 0) diff --git a/packages/taro-rn-runner/package.json b/packages/taro-rn-runner/package.json index 3b2e8e28eb50..7f8d63cd3e98 100644 --- a/packages/taro-rn-runner/package.json +++ b/packages/taro-rn-runner/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/rn-runner", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "ReactNative build tool for taro", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-rn-style-transformer/package.json b/packages/taro-rn-style-transformer/package.json index c806badde345..fba17016f433 100644 --- a/packages/taro-rn-style-transformer/package.json +++ b/packages/taro-rn-style-transformer/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/rn-style-transformer", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "提供 Taro RN 统一处理样式文件能力", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-rn-supporter/package.json b/packages/taro-rn-supporter/package.json index 950e3f70c540..ffc88f0db13e 100644 --- a/packages/taro-rn-supporter/package.json +++ b/packages/taro-rn-supporter/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/rn-supporter", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Taro rn supporter", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-rn-transformer/package.json b/packages/taro-rn-transformer/package.json index b15bdf0d6427..d7c4417523dc 100644 --- a/packages/taro-rn-transformer/package.json +++ b/packages/taro-rn-transformer/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/rn-transformer", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Taro RN 入口文件处理", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-rn/package.json b/packages/taro-rn/package.json index 5fc1e26f161d..0218f2a8af9c 100644 --- a/packages/taro-rn/package.json +++ b/packages/taro-rn/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/taro-rn", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Taro RN framework", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-router-rn/package.json b/packages/taro-router-rn/package.json index cf4cd4802cdc..a902b8df60d2 100644 --- a/packages/taro-router-rn/package.json +++ b/packages/taro-router-rn/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/router-rn", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Taro-router-rn", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-router/package.json b/packages/taro-router/package.json index 147d7571e0cc..0c4db20ebbf2 100644 --- a/packages/taro-router/package.json +++ b/packages/taro-router/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/router", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Taro-router", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-runner-utils/package.json b/packages/taro-runner-utils/package.json index 02c0c1f98215..41558745d82f 100644 --- a/packages/taro-runner-utils/package.json +++ b/packages/taro-runner-utils/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/runner-utils", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Taro runner utilities.", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-runtime-rn/package.json b/packages/taro-runtime-rn/package.json index 01a83df95333..93f443af535d 100644 --- a/packages/taro-runtime-rn/package.json +++ b/packages/taro-runtime-rn/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/runtime-rn", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "taro-runtime-rn", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-runtime/package.json b/packages/taro-runtime/package.json index 0a2fff07db8e..61dcea04a338 100644 --- a/packages/taro-runtime/package.json +++ b/packages/taro-runtime/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/runtime", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "taro runtime for mini apps.", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-runtime/src/bom/URL.ts b/packages/taro-runtime/src/bom/URL.ts index b388624156ad..59c9693a6c5c 100644 --- a/packages/taro-runtime/src/bom/URL.ts +++ b/packages/taro-runtime/src/bom/URL.ts @@ -1,4 +1,4 @@ -import { isString, isUndefined } from '@tarojs/shared' +import { isString, isUndefined, PLATFORM_TYPE } from '@tarojs/shared' import env from '../env' import { URLSearchParams } from './URLSearchParams' @@ -176,7 +176,7 @@ class TaroURL { export type { TaroURL } // Note: 小程序端 vite 打包成 commonjs,const URL = xxx 会报错,所以把 URL 改为 TaroURLProvider -export const TaroURLProvider: typeof TaroURL = process.env.TARO_PLATFORM === 'web' ? env.window.URL : TaroURL +export const TaroURLProvider: typeof TaroURL = process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB ? env.window.URL : TaroURL export function parseUrl (url = '') { const result = { diff --git a/packages/taro-runtime/src/bom/URLSearchParams.ts b/packages/taro-runtime/src/bom/URLSearchParams.ts index 812e73980d48..02ee9ab44143 100644 --- a/packages/taro-runtime/src/bom/URLSearchParams.ts +++ b/packages/taro-runtime/src/bom/URLSearchParams.ts @@ -1,4 +1,4 @@ -import { isArray } from '@tarojs/shared' +import { isArray, PLATFORM_TYPE } from '@tarojs/shared' import env from '../env' @@ -36,7 +36,7 @@ function encode (str: string) { return encodeURIComponent(str).replace(findReg, replacer) } -export const URLSearchParams = process.env.TARO_PLATFORM === 'web' ? env.window.URLSearchParams : class { +export const URLSearchParams = process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB ? env.window.URLSearchParams : class { #dict = Object.create(null) constructor (query) { diff --git a/packages/taro-runtime/src/bom/document.ts b/packages/taro-runtime/src/bom/document.ts index d94f52001ce5..b2a6f26893e0 100644 --- a/packages/taro-runtime/src/bom/document.ts +++ b/packages/taro-runtime/src/bom/document.ts @@ -1,3 +1,5 @@ +import { PLATFORM_TYPE } from '@tarojs/shared' + import { APP, BODY, @@ -44,4 +46,4 @@ function createDocument (): TaroDocument { } // Note: 小程序端 vite 打包成 commonjs,const document = xxx 会报错,所以把 document 改为 taroDocumentProvider -export const taroDocumentProvider: TaroDocument = process.env.TARO_PLATFORM === 'web' ? env.document : (env.document = createDocument()) +export const taroDocumentProvider: TaroDocument = process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB ? env.document : (env.document = createDocument()) diff --git a/packages/taro-runtime/src/bom/getComputedStyle.ts b/packages/taro-runtime/src/bom/getComputedStyle.ts index 20156a2d6922..dd54493dd838 100644 --- a/packages/taro-runtime/src/bom/getComputedStyle.ts +++ b/packages/taro-runtime/src/bom/getComputedStyle.ts @@ -1,3 +1,5 @@ +import { PLATFORM_TYPE } from '@tarojs/shared' + import env from '../env' import type { TaroElement } from '../dom/element' @@ -6,6 +8,6 @@ import type { Style } from '../dom/style' export type TGetComputedStyle = typeof window.getComputedStyle | ((el: TaroElement) => Style) // Note: 小程序端 vite 打包成 commonjs,const getComputedStyle = xxx 会报错,所以把 GetComputedStyle 改为 taroGetComputedStyleProvider -export const taroGetComputedStyleProvider: TGetComputedStyle = process.env.TARO_PLATFORM === 'web' ? env.window.getComputedStyle : function (element: TaroElement): Style { +export const taroGetComputedStyleProvider: TGetComputedStyle = process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB ? env.window.getComputedStyle : function (element: TaroElement): Style { return element.style } diff --git a/packages/taro-runtime/src/bom/history.ts b/packages/taro-runtime/src/bom/history.ts index de30fee9c231..aab00a8d2099 100644 --- a/packages/taro-runtime/src/bom/history.ts +++ b/packages/taro-runtime/src/bom/history.ts @@ -1,4 +1,4 @@ -import { isNumber, isString } from '@tarojs/shared' +import { isNumber, isString, PLATFORM_TYPE } from '@tarojs/shared' import { CONTEXT_ACTIONS } from '../constants' import { Events } from '../emitter/emitter' @@ -153,4 +153,4 @@ class TaroHistory extends Events { } export type { TaroHistory } -export const History: typeof TaroHistory = process.env.TARO_PLATFORM === 'web' ? env.window.History : TaroHistory +export const History: typeof TaroHistory = process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB ? env.window.History : TaroHistory diff --git a/packages/taro-runtime/src/bom/location.ts b/packages/taro-runtime/src/bom/location.ts index 069240a23962..a9ced9713e4e 100644 --- a/packages/taro-runtime/src/bom/location.ts +++ b/packages/taro-runtime/src/bom/location.ts @@ -1,4 +1,4 @@ -import { isNumber, isString, warn } from '@tarojs/shared' +import { isNumber, isString, PLATFORM_TYPE, warn } from '@tarojs/shared' import { CONTEXT_ACTIONS } from '../constants' import { getCurrentInstance } from '../current' @@ -312,7 +312,7 @@ class TaroLocation extends Events { } export type { TaroLocation } -export const Location: typeof TaroLocation = process.env.TARO_PLATFORM === 'web' ? env.window.Location : TaroLocation +export const Location: typeof TaroLocation = process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB ? env.window.Location : TaroLocation function generateFullUrl (val = '') { const origin = INIT_URL diff --git a/packages/taro-runtime/src/bom/navigator.ts b/packages/taro-runtime/src/bom/navigator.ts index 1454c8161925..a072da154e8c 100644 --- a/packages/taro-runtime/src/bom/navigator.ts +++ b/packages/taro-runtime/src/bom/navigator.ts @@ -1,3 +1,5 @@ +import { PLATFORM_TYPE } from '@tarojs/shared' + import env from '../env' const machine = 'Macintosh' @@ -6,7 +8,7 @@ const engine = 'AppleWebKit/534.36 (KHTML, like Gecko) NodeJS/v4.1.0 Chrome/76.0 const msg = '(' + machine + '; ' + arch + ') ' + engine -export const nav: typeof window.navigator = process.env.TARO_PLATFORM === 'web' ? env.window.navigator : { +export const nav: typeof window.navigator = process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB ? env.window.navigator : { appCodeName: 'Mozilla', appName: 'Netscape', appVersion: '5.0 ' + msg, diff --git a/packages/taro-runtime/src/bom/raf.ts b/packages/taro-runtime/src/bom/raf.ts index 3479f307fda6..855fe1584d31 100644 --- a/packages/taro-runtime/src/bom/raf.ts +++ b/packages/taro-runtime/src/bom/raf.ts @@ -1,3 +1,5 @@ +import { PLATFORM_TYPE } from '@tarojs/shared' + // https://github.com/myrne/performance-now export let now: () => number @@ -18,13 +20,13 @@ let lastTime = 0 // https://gist.github.com/paulirish/1579671 // https://gist.github.com/jalbam/5fe05443270fa6d8136238ec72accbc0 -const _raf = process.env.TARO_PLATFORM === 'web' ? requestAnimationFrame : function (callback) { +const _raf = process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB ? requestAnimationFrame : function (callback) { const _now = now() const nextTime = Math.max(lastTime + 16, _now) // First time will execute it immediately but barely noticeable and performance is gained. return setTimeout(function () { callback(lastTime = nextTime) }, nextTime - _now) } -const _caf = process.env.TARO_PLATFORM === 'web' +const _caf = process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB ? cancelAnimationFrame : function (seed) { // fix https://github.com/NervJS/taro/issues/7749 diff --git a/packages/taro-runtime/src/bom/window.ts b/packages/taro-runtime/src/bom/window.ts index a30515cffb79..f7b2235dead0 100644 --- a/packages/taro-runtime/src/bom/window.ts +++ b/packages/taro-runtime/src/bom/window.ts @@ -1,4 +1,4 @@ -import { isString } from '@tarojs/shared' +import { isString, PLATFORM_TYPE } from '@tarojs/shared' import { CONTEXT_ACTIONS } from '../constants' import { Events } from '../emitter/emitter' @@ -109,6 +109,6 @@ class TaroWindow extends Events { export type { TaroWindow } // Note: 小程序端 vite 打包成 commonjs,const window = xxx 会报错,所以把 window 改为 taroWindowProvider,location 和 history 同理 -export const taroWindowProvider: TaroWindow = process.env.TARO_PLATFORM === 'web' ? env.window : (env.window = new TaroWindow()) +export const taroWindowProvider: TaroWindow = process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB ? env.window : (env.window = new TaroWindow()) export const taroLocationProvider = taroWindowProvider.location export const taroHistoryProvider = taroWindowProvider.history diff --git a/packages/taro-runtime/src/dom-external/index.ts b/packages/taro-runtime/src/dom-external/index.ts index 5d5c79c252f5..82cbf90f310a 100644 --- a/packages/taro-runtime/src/dom-external/index.ts +++ b/packages/taro-runtime/src/dom-external/index.ts @@ -1,3 +1,5 @@ +import { PLATFORM_TYPE } from '@tarojs/shared' + import { TaroElement } from '../dom/element' import { TaroNode } from '../dom/node' import { setInnerHTML } from '../dom-external/inner-html/html' @@ -12,7 +14,7 @@ declare const ENABLE_CONTAINS: boolean declare const ENABLE_SIZE_APIS: boolean declare const ENABLE_TEMPLATE_CONTENT: boolean -if (process.env.TARO_PLATFORM !== 'web' && !(process.env.TARO_PLATFORM === 'harmony' || process.env.TARO_ENV === 'harmony')) { +if (process.env.TARO_PLATFORM !== PLATFORM_TYPE.WEB && process.env.TARO_PLATFORM !== PLATFORM_TYPE.HARMONY) { if (ENABLE_INNER_HTML) { TaroNode.extend('innerHTML', { set (html: string) { diff --git a/packages/taro-runtime/src/dsl/common.ts b/packages/taro-runtime/src/dsl/common.ts index a2bdffe5a4ab..eec8257a4a6c 100644 --- a/packages/taro-runtime/src/dsl/common.ts +++ b/packages/taro-runtime/src/dsl/common.ts @@ -2,7 +2,8 @@ import { EMPTY_OBJ, ensure, EventChannel, getComponentsAlias, hooks, internalComponents, - isArray, isFunction, isString, isUndefined, Shortcuts + isArray, isFunction, isString, isUndefined, PLATFORM_TYPE, + Shortcuts, } from '@tarojs/shared' import { raf } from '../bom/raf' @@ -69,7 +70,7 @@ export function stringify (obj?: Record) { export function getPath (id: string, options?: Record): string { const idx = id.indexOf('?') - if (process.env.TARO_PLATFORM === 'web') { + if (process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB) { return `${idx > -1 ? id.substring(0, idx) : id}${stringify(options?.stamp ? { stamp: options.stamp } : {})}` } else { return `${idx > -1 ? id.substring(0, idx) : id}${stringify(options)}` @@ -105,7 +106,7 @@ export function createPageConfig (component: any, pageName?: string, data?: Reco let prepareMountList: (() => void)[] = [] function setCurrentRouter (page: MpInstance) { - const router = process.env.TARO_PLATFORM === 'web' ? page.$taroPath : page.route || page.__route__ || page.$taroPath + const router = process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB ? page.$taroPath : page.route || page.__route__ || page.$taroPath Current.router = { params: page.$taroParams!, path: addLeadingSlash(router), @@ -132,7 +133,7 @@ export function createPageConfig (component: any, pageName?: string, data?: Reco // this.$taroPath 是页面唯一标识 const uniqueOptions = Object.assign({}, options, { $taroTimestamp: Date.now() }) const $taroPath = this.$taroPath = getPath(id, uniqueOptions) - if (process.env.TARO_PLATFORM === 'web') { + if (process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB) { config.path = $taroPath } // this.$taroParams 作为暴露给开发者的页面参数对象,可以被随意修改 @@ -143,7 +144,7 @@ export function createPageConfig (component: any, pageName?: string, data?: Reco setCurrentRouter(this) // 初始化当前页面的上下文信息 - if (process.env.TARO_PLATFORM !== 'web') { + if (process.env.TARO_PLATFORM !== PLATFORM_TYPE.WEB) { taroWindowProvider.trigger(CONTEXT_ACTIONS.INIT, $taroPath) } @@ -154,7 +155,7 @@ export function createPageConfig (component: any, pageName?: string, data?: Reco ensure(pageElement !== null, '没有找到页面实例。') safeExecute($taroPath, ON_LOAD, this.$taroParams) loadResolver() - if (process.env.TARO_PLATFORM !== 'web') { + if (process.env.TARO_PLATFORM !== PLATFORM_TYPE.WEB) { pageElement.ctx = this pageElement.performUpdate(true, cb) } else { @@ -171,7 +172,7 @@ export function createPageConfig (component: any, pageName?: string, data?: Reco [ONUNLOAD] () { const $taroPath = this.$taroPath // 销毁当前页面的上下文信息 - if (process.env.TARO_PLATFORM !== 'web') { + if (process.env.TARO_PLATFORM !== PLATFORM_TYPE.WEB) { taroWindowProvider.trigger(CONTEXT_ACTIONS.DESTORY, $taroPath) } // 触发onUnload生命周期 @@ -205,7 +206,7 @@ export function createPageConfig (component: any, pageName?: string, data?: Reco Current.page = this as any setCurrentRouter(this) // 恢复上下文信息 - if (process.env.TARO_PLATFORM !== 'web') { + if (process.env.TARO_PLATFORM !== PLATFORM_TYPE.WEB) { taroWindowProvider.trigger(CONTEXT_ACTIONS.RECOVER, this.$taroPath) } // 触发生命周期 @@ -216,7 +217,7 @@ export function createPageConfig (component: any, pageName?: string, data?: Reco }, [ONHIDE] () { // 缓存当前页面上下文信息 - if (process.env.TARO_PLATFORM !== 'web') { + if (process.env.TARO_PLATFORM !== PLATFORM_TYPE.WEB) { taroWindowProvider.trigger(CONTEXT_ACTIONS.RESTORE, this.$taroPath) } // 设置 Current 的 page 和 router @@ -231,7 +232,7 @@ export function createPageConfig (component: any, pageName?: string, data?: Reco } } - if (process.env.TARO_PLATFORM === 'web') { + if (process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB) { config.getOpenerEventChannel = () => { return EventChannel.pageChannel } @@ -302,7 +303,7 @@ export function createComponentConfig (component: React.ComponentClass, componen ensure(componentElement !== null, '没有找到组件实例。') this.$taroInstances = instances.get(path) safeExecute(path, ON_LOAD) - if (process.env.TARO_PLATFORM !== 'web') { + if (process.env.TARO_PLATFORM !== PLATFORM_TYPE.WEB) { componentElement.ctx = this componentElement.performUpdate(true) } diff --git a/packages/taro-runtime/src/env.ts b/packages/taro-runtime/src/env.ts index da0d0c0a4fa1..65cf11e20fd2 100644 --- a/packages/taro-runtime/src/env.ts +++ b/packages/taro-runtime/src/env.ts @@ -1,4 +1,4 @@ -import { EMPTY_OBJ } from '@tarojs/shared' +import { EMPTY_OBJ, PLATFORM_TYPE } from '@tarojs/shared' import type { TaroDocument } from './dom/document' @@ -8,8 +8,8 @@ interface Env { } const env: Env = { - window: process.env.TARO_PLATFORM === 'web' ? window : EMPTY_OBJ, - document: process.env.TARO_PLATFORM === 'web' ? document : EMPTY_OBJ + window: process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB ? window : EMPTY_OBJ, + document: process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB ? document : EMPTY_OBJ } export default env diff --git a/packages/taro-runtime/src/next-tick.ts b/packages/taro-runtime/src/next-tick.ts index bc59133445d8..a681af684583 100644 --- a/packages/taro-runtime/src/next-tick.ts +++ b/packages/taro-runtime/src/next-tick.ts @@ -1,3 +1,5 @@ +import { PLATFORM_TYPE } from '@tarojs/shared' + import { Current } from './current' import { TaroRootElement } from './dom/root' import env from './env' @@ -29,7 +31,7 @@ export const nextTick = (cb: TFunc, ctx?: Record) => { function next () { const pageElement: TaroRootElement | null = env.document.getElementById(path) if (pageElement?.pendingUpdate) { - if (process.env.TARO_PLATFORM === 'web') { + if (process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB) { // eslint-disable-next-line dot-notation pageElement.firstChild?.['componentOnReady']?.().then(() => { timerFunc() diff --git a/packages/taro-runtime/src/polyfill/index.ts b/packages/taro-runtime/src/polyfill/index.ts index 66d239939cce..8ba5e60274c3 100644 --- a/packages/taro-runtime/src/polyfill/index.ts +++ b/packages/taro-runtime/src/polyfill/index.ts @@ -1,4 +1,4 @@ -import { isObject } from '@tarojs/shared' +import { isObject, PLATFORM_TYPE } from '@tarojs/shared' import { handleArrayFindPolyfill, handleArrayIncludesPolyfill } from './array' import { handleIntersectionObserverPolyfill } from './intersection-observer' @@ -21,14 +21,14 @@ function handlePolyfill () { handleArrayIncludesPolyfill() } // Exit early if we're not running in a browser. - if (process.env.TARO_PLATFORM === 'web' && isObject(window)) { + if (process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB && isObject(window)) { if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'IntersectionObserver') { handleIntersectionObserverPolyfill() } } } -if (process.env.SUPPORT_TARO_POLYFILL !== 'disabled' && process.env.TARO_PLATFORM !== 'web') { +if (process.env.SUPPORT_TARO_POLYFILL !== 'disabled' && process.env.TARO_PLATFORM !== PLATFORM_TYPE.WEB) { handlePolyfill() } diff --git a/packages/taro-service/package.json b/packages/taro-service/package.json index a97a897d8900..f7417ac910eb 100644 --- a/packages/taro-service/package.json +++ b/packages/taro-service/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/service", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Taro Service", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-transformer-wx/package.json b/packages/taro-transformer-wx/package.json index a62887e7c395..f84f87dadd45 100644 --- a/packages/taro-transformer-wx/package.json +++ b/packages/taro-transformer-wx/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/transformer-wx", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Transfrom Nerv Component to Wechat mini program.", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-vite-runner/package.json b/packages/taro-vite-runner/package.json index a4b6fdd79621..d5bf3aefe565 100644 --- a/packages/taro-vite-runner/package.json +++ b/packages/taro-vite-runner/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/vite-runner", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "main": "index.js", "license": "MIT", "files": [ @@ -14,38 +14,39 @@ "mv:comp": "node ./mv-comp.js" }, "dependencies": { - "@tarojs/helper": "workspace:*", - "@tarojs/runtime": "workspace:*", - "@tarojs/runner-utils": "workspace:*", - "@tarojs/shared": "workspace:*", - "@tarojs/parse-css-to-stylesheet": "^0.0.69", + "@ampproject/remapping": "^2.3.0", "@babel/core": "^7.24.4", "@rollup/plugin-babel": "^6.0.4", "@rollup/plugin-inject": "^5.0.5", + "@rollup/plugin-terser": "^0.4.4", "@rollup/pluginutils": "^5.1.0", + "@tarojs/helper": "workspace:*", + "@tarojs/parse-css-to-stylesheet": "^0.0.69", + "@tarojs/runner-utils": "workspace:*", + "@tarojs/runtime": "workspace:*", + "@tarojs/shared": "workspace:*", "@vitejs/plugin-legacy": "^4.1.1", + "acorn-walk": "^8.3.2", + "autoprefixer": "^10.4.19", + "babel-plugin-transform-taroapi": "workspace:*", "connect-history-api-fallback": "^2.0.0", "fast-glob": "^3.3.2", + "html-minifier": "^4.0.0", "json5": "^2.2.3", "lodash": "^4.17.21", "magic-string": "^0.30.10", "mrmime": "^2.0.0", "picomatch": "^4.0.2", - "stylelint": "^16.4.0", - "postcss-load-config": "^5.0.3", - "@ampproject/remapping": "^2.3.0", - "acorn-walk": "^8.3.2", - "autoprefixer": "^10.4.19", - "babel-plugin-transform-taroapi": "workspace:*", - "html-minifier": "^4.0.0", "postcss-css-variables": "^0.19.0", "postcss-html-transform": "workspace:*", "postcss-import": "^16.1.0", + "postcss-load-config": "^5.0.3", "postcss-modules": "^6.0.0", "postcss-plugin-constparse": "workspace:*", "postcss-pxtransform": "workspace:*", "regenerator-runtime": "0.11", "sax": "1.2.4", + "stylelint": "^16.4.0", "vite-plugin-static-copy": "^0.17.1" }, "devDependencies": { diff --git a/packages/taro-vite-runner/src/harmony/asset.ts b/packages/taro-vite-runner/src/harmony/asset.ts index c87249b9b6b5..18625efe95eb 100644 --- a/packages/taro-vite-runner/src/harmony/asset.ts +++ b/packages/taro-vite-runner/src/harmony/asset.ts @@ -1,5 +1,4 @@ import path from 'node:path' -import { parse as parseUrl } from 'node:url' import { fs, getHash } from '@tarojs/helper' import MagicString from 'magic-string' @@ -243,7 +242,7 @@ export function publicFileToBuiltUrl( export function fileToUrl( id: string, config: ResolvedConfig, - pluginContext: PluginContext, + _pluginContext: PluginContext, viteCompilerContext: ViteHarmonyCompilerContext, skipPublicCheck = false, ): string { @@ -261,25 +260,32 @@ export function fileToUrl( const content = fs.readFileSync(file) // emit as asset - const { search, hash } = parseUrl(id) - const postfix = (search || '') + (hash || '') + // const { search, hash } = parseUrl(id) + // const postfix = (search || '') + (hash || '') const { cwd: appPath, taroConfig } = viteCompilerContext - const { sourceRoot = 'src' } = taroConfig + const { sourceRoot = 'src', outputRoot = 'dist' } = taroConfig const appRoot = path.resolve(appPath, sourceRoot) - const referenceId = pluginContext.emitFile({ - // Ignore directory structure for asset file names - fileName: path.relative(appRoot, file), - name: path.basename(file), - type: 'asset', - source: content, + // const referenceId = pluginContext.emitFile({ + // // Ignore directory structure for asset file names + // fileName: path.relative(appRoot, file), + // name: path.basename(file), + // type: 'asset', + // source: content, + // }) + + // const originalName = normalizePath(path.relative(config.root, file)) + // generatedAssets.get(config)!.set(referenceId, { originalName }) + + // const url = `__TARO_VITE_ASSET__${referenceId}__${postfix ? `$_${postfix}__` : ``}` // TODO_BASE + + const resourceName = path.relative(appRoot, file).replace(/^[\\/]+/, '').replace(/[\\/-]+/g, '_') + const resourcePath = path.join(process.cwd(), outputRoot, '..', 'resources/base/media', resourceName) + fs.ensureDirSync(path.dirname(resourcePath)) + fs.writeFileSync(resourcePath, content, { + encoding: 'utf-8', }) - const originalName = normalizePath(path.relative(config.root, file)) - generatedAssets.get(config)!.set(referenceId, { originalName }) - - const url = `__TARO_VITE_ASSET__${referenceId}__${postfix ? `$_${postfix}__` : ``}` // TODO_BASE - - cache.set(id, url) - return url + cache.set(id, resourcePath) + return 'resource://base/media/' + resourceName } diff --git a/packages/taro-vite-runner/src/harmony/config.ts b/packages/taro-vite-runner/src/harmony/config.ts index b5eb8e6149d5..9006ab8de090 100644 --- a/packages/taro-vite-runner/src/harmony/config.ts +++ b/packages/taro-vite-runner/src/harmony/config.ts @@ -2,6 +2,7 @@ import path from 'node:path' import { babel } from '@rollup/plugin-babel' import inject from '@rollup/plugin-inject' +import terser from '@rollup/plugin-terser' import { defaultMainFields, fs, PLATFORMS, recursiveMerge, REG_NODE_MODULES_DIR, resolveMainFilePath } from '@tarojs/helper' import { getSassLoaderOption } from '@tarojs/runner-utils' import { isArray, PLATFORM_TYPE } from '@tarojs/shared' @@ -241,6 +242,37 @@ export default function (viteCompilerContext: ViteHarmonyCompilerContext): Plugi // Note: 修复虚拟模块的依赖和引用,使其能够正确的输出 output.sanitizeFileName = (filename) => filename.replace(/^_virtual[\\/]/, '').replace(/[\0?*]/g, '_') } + const rollupPlugins: InputPluginOption[] = [ + inject(getInjectOption()), + babel(getBabelOption( + taroConfig, + { + babelOption: { + extensions: ['.js', '.jsx', '.ts', '.tsx', '.mjs', '.mts', '.es6', '.es', '.ets'], + }, + } + )), + increment({ + force: (id) => /app\.config/.test(id), + comparisonId: (id = '', files) => { + const nodeModulesDirRegx = new RegExp(REG_NODE_MODULES_DIR) + if (nodeModulesDirRegx.test(id)) return false + + const rawId = stripVirtualModulePrefix(id).replace(PAGE_SUFFIX, '') + const etx = path.extname(rawId) + id = etx ? rawId.replace(new RegExp(`${etx}$`), '') : rawId + + const list = Array.from(files) + const rgx = new RegExp(`^${id}\\.config`) + return list.some(file => rgx.test(file)) + }, + }), + ] + + // Note: Vite 官方插件禁用了 es 输出模式下的 terser 插件,这里需要手动添加 + if (!taroConfig.isWatch && getMinify(taroConfig) === 'terser') { + rollupPlugins.push(terser(recursiveMerge({}, DEFAULT_TERSER_OPTIONS, taroConfig.terser?.config || {}))) + } return { mode: getMode(taroConfig), @@ -261,32 +293,7 @@ export default function (viteCompilerContext: ViteHarmonyCompilerContext): Plugi external: HARMONY_SCOPES, makeAbsoluteExternalsRelative: 'ifRelativeSource', output: output as any, - plugins: [ - inject(getInjectOption()) as InputPluginOption, - babel(getBabelOption( - taroConfig, - { - babelOption: { - extensions: ['.js', '.jsx', '.ts', '.tsx', '.mjs', '.mts', '.es6', '.es', '.ets'], - }, - } - )) as InputPluginOption, - increment({ - force: (id) => /app\.config/.test(id), - comparisonId: (id = '', files) => { - const nodeModulesDirRegx = new RegExp(REG_NODE_MODULES_DIR) - if (nodeModulesDirRegx.test(id)) return false - - const rawId = stripVirtualModulePrefix(id).replace(PAGE_SUFFIX, '') - const etx = path.extname(rawId) - id = etx ? rawId.replace(new RegExp(`${etx}$`), '') : rawId - - const list = Array.from(files) - const rgx = new RegExp(`^${id}\\.config`) - return list.some(file => rgx.test(file)) - }, - }), - ], + plugins: rollupPlugins, }, commonjsOptions: { // TODO: 优化过滤 diff --git a/packages/taro-vite-runner/src/harmony/page.ts b/packages/taro-vite-runner/src/harmony/page.ts index 20026deebaeb..8936e00bdb2d 100644 --- a/packages/taro-vite-runner/src/harmony/page.ts +++ b/packages/taro-vite-runner/src/harmony/page.ts @@ -62,6 +62,7 @@ export default function (viteCompilerContext: ViteHarmonyCompilerContext): Plugi const tabbarPages = tabbarList.map(item => viteCompilerContext.pages.find((e: TaroHarmonyPageMeta) => { if (e.name === item.pagePath) { e.originName = item.pagePath + e.id = appendVirtualModulePrefix(e.scriptPath + PAGE_SUFFIX) return true } })!) @@ -100,6 +101,7 @@ export default function (viteCompilerContext: ViteHarmonyCompilerContext): Plugi ...page, originName: page.name, name: pageName, + id, } as TaroHarmonyPageMeta, name, this.resolve), exports: ['default'], }) diff --git a/packages/taro-vite-runner/src/harmony/postcss/constants.ts b/packages/taro-vite-runner/src/harmony/postcss/constants.ts index f541389622ae..e80df0accb52 100644 --- a/packages/taro-vite-runner/src/harmony/postcss/constants.ts +++ b/packages/taro-vite-runner/src/harmony/postcss/constants.ts @@ -35,12 +35,11 @@ export const cssNotProcessedRE = /(?:gradient|element|cross-fade|image)\(/ export const cssModuleRE = new RegExp(`\\.module${CSS_LANGS_RE.source}`) export const cssGlobalModuleRE = new RegExp(`^(?!.*\\.global\\.).*${CSS_LANGS_RE.source}`) -export const usedSuffix = '?used' export const htmlProxyRE = /(?:\?|&)html-proxy\b/ export const commonjsProxyRE = /\?commonjs-proxy/ export const inlineRE = /(?:\?|&)inline\b/ export const inlineCSSRE = /(?:\?|&)inline-css\b/ -export const usedRE = /(?:\?|&)used\b/ +export const usedRE = /(?:\?|&)used/ export const varRE = /^var\(/i export const loadParseImportRE = /(?:\?|&)load-parse-import\b/ diff --git a/packages/taro-vite-runner/src/harmony/style.ts b/packages/taro-vite-runner/src/harmony/style.ts index 4409b509dbdb..ceb297a71797 100644 --- a/packages/taro-vite-runner/src/harmony/style.ts +++ b/packages/taro-vite-runner/src/harmony/style.ts @@ -3,8 +3,7 @@ import path from 'node:path' import { transformSync } from '@babel/core' import { dataToEsm } from '@rollup/pluginutils' import { chalk, CSS_EXT, fs, REG_JS, REG_NODE_MODULES, REG_SCRIPTS, resolveSync } from '@tarojs/helper' -import { parse as parseJSXStyleFunction } from '@tarojs/parse-css-to-stylesheet' -import { isFunction } from '@tarojs/shared' +import { parse as parseJSXStyle } from '@tarojs/parse-css-to-stylesheet' import { isEqual } from 'lodash' import MagicString from 'magic-string' import stylelint from 'stylelint' @@ -21,7 +20,7 @@ import { compileCSS } from './postcss' import { commonjsProxyRE, CSS_LANGS_RE, cssModuleRE, htmlProxyRE, inlineCSSRE, inlineRE, loadParseImportRE, - SPECIAL_QUERY_RE, usedRE, usedSuffix + SPECIAL_QUERY_RE, usedRE } from './postcss/constants' import { finalizeCss, stripBomTag } from './postcss/utils' @@ -149,6 +148,10 @@ export async function stylePlugin(viteCompilerContext: ViteHarmonyCompilerContex } }, async transform(raw, id) { + if (viteCompilerContext.loaderMeta.enableParseJSXStyle && !viteCompilerContext.loaderMeta.parseJSXStyleMapCache) { + viteCompilerContext.loaderMeta.parseJSXStyleMapCache = cssMapCache + } + if ( commonjsProxyRE.test(id) || SPECIAL_QUERY_RE.test(id) || @@ -165,9 +168,11 @@ export async function stylePlugin(viteCompilerContext: ViteHarmonyCompilerContex } } + // Note: 新版本 rust 插件不需要修改 JSX 代码 + if (!isStyleRequest(id) && viteCompilerContext.loaderMeta.enableParseJSXStyle) return + if (!isStyleRequest(id)) { if (!REG_SCRIPTS.test(id)) return - const parseJSXStyle = isFunction(viteCompilerContext.loaderMeta.parseJSXStyle) ? viteCompilerContext.loaderMeta.parseJSXStyle : parseJSXStyleFunction try { const isEntry = viteCompilerContext.taroConfig.entry.app.includes(id) if (!isEntry && !globalCssCache) { @@ -207,7 +212,7 @@ export async function stylePlugin(viteCompilerContext: ViteHarmonyCompilerContex if (cssIdSet.size) { const cssRawArr = Array.from(cssIdSet).map((cssId) => { - const rawId = stripVirtualModulePrefix(cssId).replace(STYLE_SUFFIX_RE, '').replace(usedSuffix, '') + const rawId = stripVirtualModulePrefix(cssId).replace(STYLE_SUFFIX_RE, '').replace(usedRE, '') return cssCache.get(rawId) || '' }) const { code: raw_code } = parseJSXStyle(raw, cssRawArr, { @@ -259,8 +264,9 @@ export async function stylePlugin(viteCompilerContext: ViteHarmonyCompilerContex // 校验css validateStylelint(id, raw) - if (modules && !moduleCache.has(id)) { - moduleCache.set(id, modules) + const rawId = id.replace(STYLE_SUFFIX_RE, '').replace(usedRE, '') + if (modules && !moduleCache.has(rawId)) { + moduleCache.set(rawId, modules) } // track deps for build watch mode @@ -337,7 +343,7 @@ export async function stylePostPlugin(_viteCompilerContext: ViteHarmonyCompilerC const css = stripBomTag(raw) const inlined = inlineRE.test(id) - const rawId = stripVirtualModulePrefix(id).replace(STYLE_SUFFIX_RE, '').replace(usedSuffix, '') + const rawId = stripVirtualModulePrefix(id).replace(STYLE_SUFFIX_RE, '').replace(usedRE, '') const modules = cssModulesCache.get(viteConfig)!.get(rawId) // `foo.module.css` => modulesCode diff --git a/packages/taro-vite-runner/src/harmony/template/app.ts b/packages/taro-vite-runner/src/harmony/template/app.ts index 5cc8007e691a..475bb8f51f75 100644 --- a/packages/taro-vite-runner/src/harmony/template/app.ts +++ b/packages/taro-vite-runner/src/harmony/template/app.ts @@ -35,26 +35,8 @@ export default class Parser extends BaseParser { }, '') || '' } - get pxTransformConfig () { - const pxTransformOption = this.buildConfig.postcss?.pxtransform || {} - const pxTransformConfig = pxTransformOption.config || {} - pxTransformConfig.designWidth = this.buildConfig.designWidth - pxTransformConfig.deviceRatio = this.buildConfig.deviceRatio - return pxTransformConfig - } - getInitPxTransform () { - return this.transArr2Str([ - 'initPxTransform({', - this.transArr2Str([ - `designWidth: ${this.pxTransformConfig.designWidth},`, - `deviceRatio: ${JSON.stringify(this.pxTransformConfig.deviceRatio)},`, - `baseFontSize: ${this.pxTransformConfig.baseFontSize},`, - `unitPrecision: ${this.pxTransformConfig.unitPrecision},`, - `targetUnit: ${JSON.stringify(this.pxTransformConfig.targetUnit)},`, - ], 2), - '})', - ]) + return super.getInitPxTransform(this.buildConfig) } get instantiateApp () { @@ -147,12 +129,12 @@ export default class Parser extends BaseParser { const code = this.transArr2Str([ 'import type Want from "@ohos.app.ability.Want"', 'import type ohWindow from "@ohos.window"', + 'import type { AppInstance } from "@tarojs/runtime"', '', this.#setReconciler, 'import UIAbility from "@ohos.app.ability.UIAbility"', 'import AbilityConstant from "@ohos.app.ability.AbilityConstant"', 'import { callFn, context, Current, ObjectAssign, TaroAny, window } from "@tarojs/runtime"', - 'import { AppInstance } from "@tarojs/runtime/dist/runtime.esm"', 'import { initHarmonyElement, hooks } from "@tarojs/runtime"', `import createComponent, { config } from "./${path.basename(rawId, path.extname(rawId))}${TARO_COMP_SUFFIX}"`, this.#setReconcilerPost, diff --git a/packages/taro-vite-runner/src/harmony/template/base.ts b/packages/taro-vite-runner/src/harmony/template/base.ts index c2b958307f3e..e703b569f80f 100644 --- a/packages/taro-vite-runner/src/harmony/template/base.ts +++ b/packages/taro-vite-runner/src/harmony/template/base.ts @@ -1,5 +1,7 @@ import { prettyPrintJson } from '../../utils' +import type { ViteHarmonyBuildConfig } from '@tarojs/taro/types/compile/viteCompilerContext' + export default class BaseParser { prettyPrintJson = prettyPrintJson transArr2Str (array: unknown[], prefixSpace = 0, connector = '\n') { @@ -9,4 +11,28 @@ export default class BaseParser { e instanceof Array ? this.transArr2Str(e, prefixSpace, connector) : `${' '.repeat(prefixSpace)}${e}` }`.replace(/(\x20*$)/g, ''), '') } + + getPxTransformConfig (buildConfig: ViteHarmonyBuildConfig) { + const pxTransformOption = buildConfig.postcss?.pxtransform || {} + const pxTransformConfig = pxTransformOption.config || {} + pxTransformConfig.designWidth = buildConfig.designWidth + pxTransformConfig.deviceRatio = buildConfig.deviceRatio + return pxTransformConfig + } + + getInitPxTransform (buildConfig: ViteHarmonyBuildConfig) { + const pxTransformConfig = this.getPxTransformConfig(buildConfig) + + return this.transArr2Str([ + 'initPxTransform({', + this.transArr2Str([ + `designWidth: ${pxTransformConfig.designWidth},`, + `deviceRatio: ${JSON.stringify(pxTransformConfig.deviceRatio)},`, + `baseFontSize: ${pxTransformConfig.baseFontSize},`, + `unitPrecision: ${pxTransformConfig.unitPrecision},`, + `targetUnit: ${JSON.stringify(pxTransformConfig.targetUnit)},`, + ], 2), + '})', + ]) + } } diff --git a/packages/taro-vite-runner/src/harmony/template/page.ts b/packages/taro-vite-runner/src/harmony/template/page.ts index 2862dcac560a..4780948784e8 100644 --- a/packages/taro-vite-runner/src/harmony/template/page.ts +++ b/packages/taro-vite-runner/src/harmony/template/page.ts @@ -22,6 +22,7 @@ export interface IMethod { } export interface TaroHarmonyPageMeta extends VitePageMeta { + id: string originName: string entryOption?: Record @@ -75,6 +76,10 @@ export default class Parser extends BaseParser { }, '') || '' } + getInitPxTransform () { + return super.getInitPxTransform(this.buildConfig) + } + isEnable (app?: boolean, page?: boolean) { if (app && page !== false) return true return !!page @@ -1013,18 +1018,30 @@ this.removeTabBarEvent()` : 'callFn(this.page?.onUnload, this)']) } const importList = [ 'import type Taro from "@tarojs/taro/types"', - 'import type { TFunc } from "@tarojs/runtime/dist/runtime.esm"', + 'import type { PageInstance, TaroAny, TaroElement, TaroObject, TaroNode, TaroViewElement, TFunc } from "@tarojs/runtime"', 'import type common from "@ohos.app.ability.common"', '', isBlended ? this.#setReconciler : '', 'import router from "@ohos.router"', 'import { TaroView } from "@tarojs/components"', 'import { getSystemInfoSync } from "@tarojs/taro"', - 'import { initHarmonyElement, bindFn, callFn, convertNumber2VP, Current, ObjectAssign, TaroAny, TaroElement, TaroObject, TaroNode, TaroViewElement, window, document } from "@tarojs/runtime"', - 'import { eventCenter, PageInstance } from "@tarojs/runtime/dist/runtime.esm"', + 'import { eventCenter, bindFn, callFn, convertNumber2VP, Current, document, initHarmonyElement, ObjectAssign, window } from "@tarojs/runtime"', `import { createLazyChildren } from "${renderPath}"`, ] + if (this.isTabbarPage) { + importList.push( + ...this.tabbarList.map((e, i) => `import page${i}, { config as config${i} } from './${e.pagePath}${TARO_COMP_SUFFIX}'`), + ) + } else { + importList.push( + `import createComponent, { config } from "${path.resolve(targetRoot, (page as TaroHarmonyPageMeta).originName) + TARO_COMP_SUFFIX}"`, + ) + } + if (isBlended && this.#setReconcilerPost) { + importList.push(this.#setReconcilerPost) + } + const modifyPageImport = page instanceof Array ? page[0].modifyPageImport : page.modifyPageImport if (isFunction(modifyPageImport)) { modifyPageImport.call(this, importList, page) @@ -1032,26 +1049,18 @@ this.removeTabBarEvent()` : 'callFn(this.page?.onUnload, this)']) const code = this.transArr2Str([ ...importList, - this.isTabbarPage - ? [ - this.tabbarList.map((e, i) => `import page${i}, { config as config${i} } from './${e.pagePath}${TARO_COMP_SUFFIX}'`), - isBlended ? this.#setReconcilerPost : null, - '', - `const createComponent = [${this.tabbarList.map((_, i) => `page${i}`).join(', ')}]`, - `const config = [${this.tabbarList.map((_, i) => `config${i}`).join(', ')}]`, - '', - 'interface ITabBarItem extends Taro.TabBarItem {', - this.transArr2Str([ - 'key?: number', - 'badgeText?: string', - 'showRedDot?: boolean', - ], 2), - '}', - ] - : [ - `import createComponent, { config } from "${path.resolve(targetRoot, (page as TaroHarmonyPageMeta).originName) + TARO_COMP_SUFFIX}"`, - isBlended && this.#setReconcilerPost ? this.#setReconcilerPost : null, - ], + this.isTabbarPage ? [ + `const createComponent = [${this.tabbarList.map((_, i) => `page${i}`).join(', ')}]`, + `const config = [${this.tabbarList.map((_, i) => `config${i}`).join(', ')}]`, + '', + 'interface ITabBarItem extends Taro.TabBarItem {', + this.transArr2Str([ + 'key?: number', + 'badgeText?: string', + 'showRedDot?: boolean', + ], 2), + '}', + ] : null, '', 'const sysInfo: TaroAny = getSystemInfoSync()', this.getInstantiatePage(page), @@ -1070,11 +1079,12 @@ this.removeTabBarEvent()` : 'callFn(this.page?.onUnload, this)']) parseEntry (rawId: string, page: TaroHarmonyPageMeta) { const { creatorLocation, importFrameworkStatement } = this.loaderMeta + const entryOption = page instanceof Array ? page[0].entryOption : page.entryOption const isBlended = this.buildConfig.blended || this.buildConfig.isBuildNativeComp let createFn = isBlended ? 'createNativePageConfig' : 'createPageConfig' - - const nativeCreatePage = `createNativePageConfig(component, '${page.name}', React, ReactDOM, config)` - let createPageOrComponent = isBlended ? nativeCreatePage : `createPageConfig(component, '${page.name}', config)` + const pageName = entryOption?.routeName || page.name + const nativeCreatePage = `createNativePageConfig(component, '${pageName}', React, ReactDOM, config)` + let createPageOrComponent = isBlended ? nativeCreatePage : `createPageConfig(component, '${pageName}', config)` // 如果是pure,说明不是一个页面,而是一个组件,这个时候修改import和createPage if (this.isPure) { @@ -1085,8 +1095,10 @@ this.removeTabBarEvent()` : 'callFn(this.page?.onUnload, this)']) return this.transArr2Str([ `import { ${createFn} } from '${creatorLocation}'`, `import component from "${escapePath(rawId)}"`, + isBlended ? 'import { initPxTransform } from "@tarojs/taro"' : null, importFrameworkStatement, `export const config = ${this.prettyPrintJson(page.config)}`, + isBlended ? this.getInitPxTransform() : null, page?.config.enableShareTimeline ? 'component.enableShareTimeline = true' : null, page?.config.enableShareAppMessage ? 'component.enableShareAppMessage = true' : null, `export default () => ${createPageOrComponent}`, diff --git a/packages/taro-vite-runner/src/harmony/template/render.ts b/packages/taro-vite-runner/src/harmony/template/render.ts index e84f444c2d73..c79dbbd64413 100644 --- a/packages/taro-vite-runner/src/harmony/template/render.ts +++ b/packages/taro-vite-runner/src/harmony/template/render.ts @@ -279,6 +279,7 @@ export default class RenderParser extends BaseParser { name: 'StickySection', condition: `item.tagName === 'STICKY-SECTION'`, type: 'TaroViewElement', + extra: '.reuseId(item._nid.toString())' }, { name: 'ListView', diff --git a/packages/taro-vite-runner/src/utils/compiler/harmony.ts b/packages/taro-vite-runner/src/utils/compiler/harmony.ts index 7dfc7083fa0f..8e2da1822881 100644 --- a/packages/taro-vite-runner/src/utils/compiler/harmony.ts +++ b/packages/taro-vite-runner/src/utils/compiler/harmony.ts @@ -29,7 +29,7 @@ import type { VitePageMeta, } from '@tarojs/taro/types/compile/viteCompilerContext' -function readJsonSync(file: string) { +export function readJsonSync(file: string) { const ext = path.extname(file) if (ext === '.json5') { const raw = fs.readFileSync(file, 'utf-8') diff --git a/packages/taro-webpack5-prebundle/package.json b/packages/taro-webpack5-prebundle/package.json index 94e35ff615b6..8b59590f2722 100644 --- a/packages/taro-webpack5-prebundle/package.json +++ b/packages/taro-webpack5-prebundle/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/webpack5-prebundle", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Taro app webpack5 prebundle", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-webpack5-runner/package.json b/packages/taro-webpack5-runner/package.json index 8ce1da466a21..0cfdb94dda3b 100644 --- a/packages/taro-webpack5-runner/package.json +++ b/packages/taro-webpack5-runner/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/webpack5-runner", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Taro app runner", "author": "O2Team", "license": "MIT", diff --git a/packages/taro-with-weapp/package.json b/packages/taro-with-weapp/package.json index 5e343c8f30c6..3c831567abe0 100644 --- a/packages/taro-with-weapp/package.json +++ b/packages/taro-with-weapp/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/with-weapp", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "taroize 之后的运行时", "author": "O2Team", "license": "MIT", diff --git a/packages/taro/package.json b/packages/taro/package.json index c9697708c6c6..fad8061b5f69 100644 --- a/packages/taro/package.json +++ b/packages/taro/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/taro", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "Taro framework", "author": "O2Team", "license": "MIT", diff --git a/packages/taroize/package.json b/packages/taroize/package.json index f6b0de96a8ff..0ea84bc8ff47 100644 --- a/packages/taroize/package.json +++ b/packages/taroize/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/taroize", - "version": "4.0.3-alpha.4", + "version": "4.0.3-alpha.5", "description": "转换原生微信小程序代码为 Taro 代码", "author": "O2Team", "license": "MIT", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9076dc0470af..13ac8d2b3809 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2407,6 +2407,9 @@ importers: '@rollup/plugin-inject': specifier: ^5.0.5 version: 5.0.5(rollup@3.29.4) + '@rollup/plugin-terser': + specifier: ^0.4.4 + version: 0.4.4(rollup@3.29.4) '@rollup/pluginutils': specifier: ^5.1.0 version: 5.1.0(rollup@3.29.4) @@ -5617,7 +5620,7 @@ packages: debug: 3.2.7 eol: 0.9.1 get-port: 3.2.0 - glob: registry.npmjs.org/glob@7.2.3 + glob: 7.2.3 lodash: 4.17.21 mkdirp: 0.5.6 password-prompt: 1.1.3 @@ -6170,7 +6173,7 @@ packages: chalk: 4.1.2 collect-v8-coverage: 1.0.2 exit: 0.1.2 - glob: registry.npmjs.org/glob@7.2.3 + glob: 7.2.3 graceful-fs: 4.2.11 istanbul-lib-coverage: 3.2.2 istanbul-lib-instrument: 6.0.2 @@ -7070,7 +7073,7 @@ packages: chalk: 4.1.2 cosmiconfig: 5.2.1 deepmerge: 4.3.1 - glob: registry.npmjs.org/glob@7.2.3 + glob: 7.2.3 joi: 17.13.1 transitivePeerDependencies: - encoding @@ -7873,6 +7876,21 @@ packages: rollup: 4.18.0 dev: false + /@rollup/plugin-terser@0.4.4(rollup@3.29.4): + resolution: {integrity: sha512-XHeJC5Bgvs8LfukDwWZp7yeqin6ns8RTl2B9avbejt6tZqsqvVoWI7ZTQrcNsfKEDWBTnTxM8nMDkO2IFFbd0A==, tarball: https://registry.npmjs.org/@rollup/plugin-terser/-/plugin-terser-0.4.4.tgz} + engines: {node: '>=14.0.0'} + peerDependencies: + rollup: ^2.0.0||^3.0.0||^4.0.0 + peerDependenciesMeta: + rollup: + optional: true + dependencies: + rollup: 3.29.4 + serialize-javascript: 6.0.2 + smob: 1.5.0 + terser: 5.31.0 + dev: false + /@rollup/plugin-typescript@11.1.6(rollup@3.29.4)(tslib@2.6.2)(typescript@5.4.5): resolution: {integrity: sha512-R92yOmIACgYdJ7dJ97p4K69I8gg6IEHt8M7dUBxN3W6nrO8uUxX5ixl0yU/N3aZTi8WhPuICvOHXQvF6FaykAA==, tarball: https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-11.1.6.tgz} engines: {node: '>=14.0.0'} @@ -11291,7 +11309,7 @@ packages: dependencies: '@npmcli/fs': 3.1.1 fs-minipass: 3.0.3 - glob: registry.npmjs.org/glob@10.4.1 + glob: 10.4.1 lru-cache: 10.2.2 minipass: 7.1.2 minipass-collect: 2.0.1 @@ -15630,7 +15648,6 @@ packages: minimatch: 9.0.4 minipass: 7.1.2 path-scurry: 1.11.1 - dev: true /glob@6.0.4: resolution: {integrity: sha512-MKZeRNyYZAVVVG1oZeLaWie1uweH40m9AZwIwxyPbTSX4hHrVYSzLg0Ro5Z5R7XKkIX+Cc6oD1rqeDJnwsB8/A==, tarball: https://registry.npmjs.org/glob/-/glob-6.0.4.tgz} @@ -24138,6 +24155,10 @@ packages: resolution: {integrity: sha512-h+z7HKHYXj6wJU+AnS/+IH8Uh9fdcX1Lrhg1/VMdf9PwoBQXFcXiAdsy2tSK0P6gKwJLXp02r90ahUCqHk9rrw==, tarball: https://registry.npmjs.org/slugify/-/slugify-1.6.6.tgz} engines: {node: '>=8.0.0'} + /smob@1.5.0: + resolution: {integrity: sha512-g6T+p7QO8npa+/hNx9ohv1E5pVCmWrVCUzUXJyLdMmftX6ER0oiWY/w9knEonLpnOp6b6FenKnMfR8gqwWdwig==, tarball: https://registry.npmjs.org/smob/-/smob-1.5.0.tgz} + dev: false + /snake-case@3.0.4: resolution: {integrity: sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg==, tarball: https://registry.npmjs.org/snake-case/-/snake-case-3.0.4.tgz} dependencies: @@ -27205,13 +27226,6 @@ packages: balanced-match: 1.0.2 concat-map: registry.npmjs.org/concat-map@0.0.1 - registry.npmjs.org/brace-expansion@2.0.1: - resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==, registry: https://registry.yarnpkg.com/, tarball: https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz} - name: brace-expansion - version: 2.0.1 - dependencies: - balanced-match: 1.0.2 - registry.npmjs.org/color-convert@1.9.3: resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==, registry: https://registry.yarnpkg.com/, tarball: https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz} name: color-convert @@ -27229,45 +27243,16 @@ packages: name: concat-map version: 0.0.1 - registry.npmjs.org/fs.realpath@1.0.0: - resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==, registry: https://registry.yarnpkg.com/, tarball: https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz} - name: fs.realpath - version: 1.0.0 - - registry.npmjs.org/glob@10.4.1: - resolution: {integrity: sha512-2jelhlq3E4ho74ZyVLN03oKdAZVUa6UDZzFLVH1H7dnoax+y9qyaq8zBkfDIggjniU19z0wU18y16jMB2eyVIw==, registry: https://registry.yarnpkg.com/, tarball: https://registry.npmjs.org/glob/-/glob-10.4.1.tgz} - name: glob - version: 10.4.1 - engines: {node: '>=16 || 14 >=14.18'} - hasBin: true - dependencies: - foreground-child: 3.1.1 - jackspeak: 3.1.2 - minimatch: registry.npmjs.org/minimatch@9.0.4 - minipass: 7.1.2 - path-scurry: 1.11.1 - - registry.npmjs.org/glob@7.2.3: - resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==, registry: https://registry.yarnpkg.com/, tarball: https://registry.npmjs.org/glob/-/glob-7.2.3.tgz} - name: glob - version: 7.2.3 - deprecated: Glob versions prior to v9 are no longer supported - dependencies: - fs.realpath: registry.npmjs.org/fs.realpath@1.0.0 - inflight: registry.npmjs.org/inflight@1.0.6 - inherits: registry.npmjs.org/inherits@2.0.4 - minimatch: registry.npmjs.org/minimatch@3.1.2 - once: registry.npmjs.org/once@1.4.0 - path-is-absolute: registry.npmjs.org/path-is-absolute@1.0.1 - registry.npmjs.org/inflight@1.0.6: resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==, registry: https://registry.yarnpkg.com/, tarball: https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz} name: inflight version: 1.0.6 deprecated: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful. + requiresBuild: true dependencies: once: registry.npmjs.org/once@1.4.0 wrappy: registry.npmjs.org/wrappy@1.0.2 + optional: true registry.npmjs.org/inherits@2.0.4: resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==, registry: https://registry.yarnpkg.com/, tarball: https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz} @@ -27287,14 +27272,6 @@ packages: dependencies: brace-expansion: registry.npmjs.org/brace-expansion@1.1.11 - registry.npmjs.org/minimatch@9.0.4: - resolution: {integrity: sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==, registry: https://registry.yarnpkg.com/, tarball: https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz} - name: minimatch - version: 9.0.4 - engines: {node: '>=16 || 14 >=14.17'} - dependencies: - brace-expansion: registry.npmjs.org/brace-expansion@2.0.1 - registry.npmjs.org/once@1.4.0: resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==, registry: https://registry.yarnpkg.com/, tarball: https://registry.npmjs.org/once/-/once-1.4.0.tgz} name: once