Skip to content

Feat harmony mode#1697

Merged
hiyuki merged 18 commits intomasterfrom
feat-harmony-mode
Apr 8, 2025
Merged

Feat harmony mode#1697
hiyuki merged 18 commits intomasterfrom
feat-harmony-mode

Conversation

@Blackgan3
Copy link
Collaborator

  • 增加 harmony mode

# Conflicts:
#	packages/api-proxy/src/platform/api/system/rnSystem.js
#	packages/core/@types/global.d.ts
#	packages/core/src/convertor/convertor.js
#	packages/core/src/core/proxy.js
#	packages/core/src/platform/patch/index.js
#	packages/core/src/platform/patch/react/getDefaultOptions.ios.js
#	packages/webpack-plugin/lib/platform/style/wx/index.js
#	packages/webpack-plugin/lib/platform/template/wx/component-config/picker-view.js
# Conflicts:
#	packages/core/src/platform/patch/getDefaultOptions.ios.js
#	packages/webpack-plugin/lib/platform/template/wx/component-config/view.js
#	packages/webpack-plugin/lib/runtime/components/react/mpx-web-view.tsx
# Conflicts:
#	packages/webpack-plugin/lib/runtime/components/react/mpx-video.tsx
const getDeviceInfo = function () {
const deviceInfo = {}
if (__mpx_mode__ === 'android') {
if (__mpx_mode__ === 'android' || __mpx_mode__ === 'harmony') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!== ios

export default function getBuiltInMixins ({ type, rawOptions = {} }) {
let bulitInMixins
if (__mpx_mode__ === 'ios' || __mpx_mode__ === 'android') {
if (__mpx_mode__ === 'ios' || __mpx_mode__ === 'android' || __mpx_mode__ === 'harmony') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

用utils中的isReact

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

下面改成isWeb


// TODO 此部分内容在native-stack可删除,用setOptions设置
if (__mpx_mode__ === 'android') {
if (__mpx_mode__ === 'android' || __mpx_mode__ === 'harmony') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!== ios

}
if (isReact(options.mode) && options.srcMode !== 'wx') {
errors.push('MpxWebpackPlugin supports mode to be "ios" or "android" only when srcMode is set to "wx"!')
errors.push('MpxWebpackPlugin supports mode to be "ios" or "android" of "harmony" only when srcMode is set to "wx"!')
Copy link
Collaborator

@hiyuki hiyuki Apr 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"ios | android | harmony"

}
const cssMap = formatAbbreviation({ prop, value, selector }, { mode })
if (mode === 'android') return cssMap
if (mode === 'android' || mode === 'harmony') return cssMap
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!== ios

value
}
},
harmony ({ name, value }, { eventRules, el }) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

抽个复用的构造器函数复用一下

error(`React native environment does not support [${eventName}] event!`)
}
},
harmony (eventName) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复用而不要copy

})

if (__mpx_mode__ === 'android') {
if (__mpx_mode__ === 'android' || __mpx_mode__ === 'harmony') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!== ios

animated: false
})
}, isAndroid ? 200 : 0)
}, isAndroid || isHarmony ? 200 : 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

用isIOS判断

{
detail: {
position: __mpx_mode__ === 'android' ? seekTime * 1000 : seekTime
position: __mpx_mode__ === 'android' || __mpx_mode__ === 'harmony' ? seekTime * 1000 : seekTime
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ios

source.drm = {
type: DRMType.FAIRPLAY,
certificateUrl: __mpx_mode__ === 'android' ? provisionUrl : certificateUrl,
certificateUrl: __mpx_mode__ === 'android' || __mpx_mode__ === 'harmony' ? provisionUrl : certificateUrl,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ios


const _reload = function () {
if (__mpx_mode__ === 'android') {
if (__mpx_mode__ === 'android' || __mpx_mode__ === 'harmony') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ios


const _onLoadProgress = function (event: WebViewProgressEvent) {
if (__mpx_mode__ === 'android') {
if (__mpx_mode__ === 'android' || __mpx_mode__ === 'harmony') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ios

}
const onLoadEnd = function (res: WebViewEvent) {
if (__mpx_mode__ === 'android') {
if (__mpx_mode__ === 'android' || __mpx_mode__ === 'harmony') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ios


export const isIOS = __mpx_mode__ === 'ios'
export const isAndroid = __mpx_mode__ === 'android'
export const isHarmony = __mpx_mode__ === 'harmony'
Copy link
Collaborator

@hiyuki hiyuki Apr 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

把组件内的局部定义指向这个

const { dash2hump } = require('../../../utils/hump-dash')

module.exports = function getSpec ({ warn, error }) {
function rnDirectiveEventHandle ({ name, value, eventRules, el, mode, match }) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个定义为一个高阶函数,传一个mode过去就行

@hiyuki hiyuki merged commit 6b63ecb into master Apr 8, 2025
6 checks passed
@hiyuki hiyuki deleted the feat-harmony-mode branch April 8, 2025 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants