Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into 3.0_doc
Browse files Browse the repository at this point in the history
  • Loading branch information
zealotchen0 committed Jun 17, 2024
2 parents 31f16e8 + c6b8b0f commit 2025658
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 124 deletions.
4 changes: 2 additions & 2 deletions docs/development/_sidebar.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!-- docs/_sidebar.md -->
- [Demo体验](development/demo.md)
- 前端接入
- [Hippy React&Vue接入指引](development/react-vue-integration-guidelines.md)
- [Hippy React&Vue 3.x升级指引](development/react-vue-3.0-upgrade-guidelines.md)
- [Hippy-React&Vue 3.x SDK集成指引](development/react-vue-3.0-integration-guidelines.md)
- [Hippy-React&Vue 3.x SDK升级指引](development/react-vue-3.0-upgrade-guidelines.md)
- [Web同构接入指引](development/web-integration-guidelines.md)
- 终端接入
- [Android 3.x SDK集成指引](development/android-3.0-integration-guidelines.md)
Expand Down
164 changes: 58 additions & 106 deletions docs/development/android-3.0-upgrade-guidelines.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export default function app() {

# hippy-vue

>注意:因vue2.x版本将于年底停止更新,建议用户升级至使用vue3.x版本的@hippy/vue-next
>注意:因vue2.x版本将停止更新,建议用户升级至使用vue3.x版本的@hippy/vue-next
[[hippy-vue 介绍]](api/hippy-vue/introduction.md) [[范例工程]](//github.com/Tencent/Hippy/tree/master/examples/hippy-vue-demo)

Expand Down
39 changes: 32 additions & 7 deletions docs/development/react-vue-3.0-upgrade-guidelines.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Hippy React&Vue 3.x SDK升级指引

> 这篇教程,主要介绍Hippy React&Vue 如何升级3.0版本以及升级后的相关验证关注点。
> 这篇教程,主要介绍 Hippy React&Vue&Vue-next 如何升级3.0版本以及升级后的相关验证关注点。
---

# 依赖升级
# 升级依赖项变更

## hippy-react

Expand All @@ -29,7 +29,7 @@
3)如果使用了 @hippy/react-web 包做h5同构,则需要升级 @hippy/react-web 到 3.2.0-beta 及以上
```

Hippy-React 在升级3.0可以完全兼容之前的版本,除了升级如上依赖,业务代码不需要做修改。
需要业务使用新的 hippy-react 重编 js common包

## hippy-vue

Expand All @@ -47,9 +47,7 @@ Hippy-React 在升级3.0可以完全兼容之前的版本,除了升级如上
6)vue 和 vue-router 等vue相关依赖无需升级
```

Hippy-Vue 在升级3.0可以完全兼容之前的版本,除了升级如上依赖,业务代码不需要做修改。


需要业务使用新的 hippy-vue 重编 js common包

## hippy-vue-next

Expand All @@ -65,11 +63,38 @@ Hippy-Vue 在升级3.0可以完全兼容之前的版本,除了升级如上依
4)vue 和 vue-router 等vue相关依赖无需升级
```

Hippy-Vue-Next 在升级3.0可以完全兼容之前的版本,除了升级如上依赖,业务代码不需要做修改。
需要业务使用新的 hippy-vue-next 重编 js common包

</br>
</br>

# 接入与使用方式变更

接入 Hippy-React、Hippy-Vue、Hippy-Vue-Next SDK 代码无变化,可参考 [前端集成指引](development/react-vue-3.0-integration-guidelines.md)

具体变化点如下:

1. iOS 新增节点层级优化算法,Android 优化了现有的层级优化算法:
该算法会将仅参与布局的View节点优化去除,从而提升渲染效率。请注意 !!!由于该算法的存在,可能导致依赖特定UI层级结构的native组件发生找不到特定View的异常。
此时,可以通过前端代码中给特定 View 增加 collapsable: 'false' 属性来禁止该节点被优化算法去除。


# 组件变更

1. dialog 组件的第一个子元素不能设置 { position: absolute } 样式,如果想将 dialog 内容铺满全屏,可以给第一个子元素设置 { flex: 1 } 样式或者显式设置 width 和 height 数值

2. Image 组件废弃了 source、 sources、srcs 字段,建议使用 src 字段代表图片 url

3. iOS Image 组件默认没有实现图片缓存 (由于实现机制的变化),需要业务 iOS端自行实现缓存管理,详细可参考 [iOS 升级指引](development/ios-3.0-upgrade-guidelines.md)

# 接口定义变更

1. hippy-react 不再导出RNfqb、RNfqbRegister、RNfqbEventEmitter、RNfqbEventListener 方法

2. hippy-react animation 模块不再有 destory() 方法的错误写法兼容,统一用 destroy()

3. hippy-react animation 事件监听不再支持 onRNfqbAnimationXX 兼容写法,统一用 onHippyAnimationXX 或者 onAnimationXX

# 验证关注点

一、Hippy 3.0 前端架构升级主要有如下改动点:
Expand Down
35 changes: 35 additions & 0 deletions docs/feature/feature3.0/image-decoder-adapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# ImageDecoderAdapter

---

## 背景

3.0我们在HippyEngine引擎初始化参数中增加了ImageDecoderAdapter的设置,如果有开发者业务中有使用到特殊格式的图片,如SharpP、avif等,可以通过设置ImageDecoderAdapter来对接你的自定义图片解码器,具体接口描述如下:

## 3.0 图片解码Adapter接口定义

### ImageDecoderAdapter Public methods

```java
boolean preDecode(@NonNull byte[] data,
@Nullable Map<String, Object> initProps,
@NonNull ImageDataHolder imageHolder,
@NonNull BitmapFactory.Options options);
```

该接口在拉取到图片原始数据的时候会调用,解码的结果可以通过image data holder提供的setBitmap或者setDrawable接口设置到holder中,并且返回true,表示不需要sdk再做解码操作,如果返回false表示需要sdk做默认的解码操作。

```java
void afterDecode(@Nullable Map<String, Object> initProps,
@NonNull ImageDataHolder imageHolder,
@NonNull BitmapFactory.Options options);
```


该接口在解码结束后会调用,为开发者提供二次处理bitmap的机会, 比如要对bitmap做高斯模糊。

```java
void destroyIfNeeded();
```

引擎退出销毁时调用,释放adapter可能占用的资源
2 changes: 1 addition & 1 deletion driver/js/packages/hippy-vue-native-components/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Hippy Vue Native Components

> The package contains the **Native only** components provide by Hippy.
> The package contains the **Native only** components provided by Hippy.
> For web alternative could use `hippy-vue-web-components`(it's not exist yet).
![Hippy Group](https://img.shields.io/badge/group-Hippy-blue.svg)
Expand Down
12 changes: 7 additions & 5 deletions driver/js/src/scope.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,13 @@ Scope::~Scope() {
*/
#else
auto engine = engine_.lock();
FOOTSTONE_CHECK(engine);
auto key = wrapper_.get();
engine->ClearWeakCallbackWrapper(key);
engine->ClearFunctionWrapper(key);
engine->ClearClassTemplate(key);
FOOTSTONE_DCHECK(engine);
if (engine) {
auto key = wrapper_.get();
engine->ClearWeakCallbackWrapper(key);
engine->ClearFunctionWrapper(key);
engine->ClearClassTemplate(key);
}
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,23 +185,30 @@ - (HippyShadowView *)shadowView {
}

HIPPY_CUSTOM_SHADOW_PROPERTY(fontFamily, NSString, HippyShadowTextView) {
view.font = [HippyFont updateFont:view.font withFamily:json];
// Convert fontName to fontFamily if needed
NSString *familyName = [self familyNameWithCSSNameMatching:json];
view.font = [HippyFont updateFont:view.font withFamily:familyName];
}

HIPPY_CUSTOM_VIEW_PROPERTY(fontSize, NSNumber, HippyBaseTextInput) {
UIFont *theFont = [HippyFont updateFont:view.font withSize:json ?: @(defaultView.font.pointSize)];
view.font = theFont;
}

HIPPY_CUSTOM_VIEW_PROPERTY(fontWeight, NSString, __unused HippyBaseTextInput) {
UIFont *theFont = [HippyFont updateFont:view.font withWeight:json]; // defaults to normal
view.font = theFont;
}

HIPPY_CUSTOM_VIEW_PROPERTY(fontStyle, NSString, __unused HippyBaseTextInput) {
UIFont *theFont = [HippyFont updateFont:view.font withStyle:json];
view.font = theFont; // defaults to normal
}

HIPPY_CUSTOM_VIEW_PROPERTY(fontFamily, NSString, HippyBaseTextInput) {
view.font = [HippyFont updateFont:view.font withFamily:json ?: defaultView.font.familyName];
// Convert fontName to fontFamily if needed
NSString *familyName = [self familyNameWithCSSNameMatching:json];
view.font = [HippyFont updateFont:view.font withFamily:familyName ?: defaultView.font.familyName];
}

- (HippyViewManagerUIBlock)uiBlockToAmendWithShadowView:(HippyShadowView *)hippyShadowView {
Expand All @@ -211,4 +218,24 @@ - (HippyViewManagerUIBlock)uiBlockToAmendWithShadowView:(HippyShadowView *)hippy
viewRegistry[componentTag].contentInset = padding;
};
}


#pragma mark - Private

/// Get the
/// JS side usually pass a `fontName` instead of `fontFamily`
/// - Parameter json: id
- (NSString *)familyNameWithCSSNameMatching:(id)json {
NSString *familyName = json;
if (json && ![[UIFont familyNames] containsObject:json]) {
// Not a real FamilyName
// Using CSS name matching semantics.
// fontSize here is just a placeholder for getting font.
UIFont *cssFont = [UIFont fontWithName:json size:14.0];
familyName = cssFont.familyName;
}
return familyName;
}


@end

0 comments on commit 2025658

Please sign in to comment.