Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/vue-next-style-hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
open-hippy authored Jul 14, 2023
2 parents 5560421 + a431df4 commit 33dc927
Show file tree
Hide file tree
Showing 34 changed files with 347 additions and 371 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void setShadowRadius(float shadowRadius) {
}
}

@HippyControllerProps(name = NodeProps.DIRECTION)
@HippyControllerProps(name = NodeProps.DIRECTION, defaultType = HippyControllerProps.STRING, defaultString = "ltr")
public void setDirection(String direction) {
if (TextUtils.isEmpty(direction)) {
return;
Expand Down Expand Up @@ -144,7 +144,7 @@ public void setOverflow(String overflow) {
}

@SuppressWarnings("SwitchStatementWithTooFewBranches")
@HippyControllerProps(name = NodeProps.DISPLAY)
@HippyControllerProps(name = NodeProps.DISPLAY, defaultType = HippyControllerProps.STRING)
public void setDisplay(String display) {
FlexNodeStyle.Display flexDisplay = FlexNodeStyle.Display.DISPLAY_FLEX;
switch (display) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,8 @@ public void setListData() {
}

renderNodeCount = listAdapter.getRenderNodeCount();
if (renderNodeCount > 0) {
if (mInitialContentOffset > 0 && getChildCount() > 0) {
scrollToInitContentOffset();
}
if (renderNodeCount > 0 && mInitialContentOffset > 0) {
scrollToInitContentOffset();
}
//notifyDataSetChanged 本身是可以触发requestLayout的,但是Hippy框架下 HippyRootView 已经把
//onLayout方法重载写成空方法,requestLayout不会回调孩子节点的onLayout,这里需要自己发起dispatchLayout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,11 @@ protected void handleGetImageSuccess() {
protected void handleGetImageFail(Throwable throwable) {
// send onError event
if (mShouldSendImageEvent[ImageEvent.ONERROR.ordinal()]) {
getOnErrorEvent().send(this, null);
HippyMap map = new HippyMap();
map.pushString("error", String.valueOf(throwable));
map.pushInt("errorCode", -1);
map.pushString("errorURL", mUrl != null ? mUrl : "");
getOnErrorEvent().send(this, map);
}
// send onLoadEnd event
if (mShouldSendImageEvent[ImageEvent.ONLOAD_END.ordinal()]) {
Expand Down
4 changes: 2 additions & 2 deletions core/src/napi/jsc/jsc_ctx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ JSValueRef InvokeJsCallback(JSContextRef ctx,
void* external_data = func_wrapper->data;
CallbackInfo cb_info;
cb_info.SetSlot(func_data->global_external_data);
auto context = const_cast<JSGlobalContextRef>(ctx);
auto context = JSContextGetGlobalContext(ctx);
cb_info.SetReceiver(std::make_shared<JSCCtxValue>(context, object));
for (size_t i = 0; i < argumentCount; i++) {
cb_info.AddValue(std::make_shared<JSCCtxValue>(context, arguments[i]));
Expand Down Expand Up @@ -110,7 +110,7 @@ static JSValueRef JSObjectGetPropertyCallback(
JSValueRef *exception_ref) {

FuncData* func_data = reinterpret_cast<FuncData*>(JSObjectGetPrivate(object));
auto context = const_cast<JSGlobalContextRef>(ctx);
auto context = JSContextGetGlobalContext(ctx);
auto func_wrapper = reinterpret_cast<FuncWrapper*>(func_data->func_wrapper);
auto js_cb = func_wrapper->cb;
void* external_data = func_wrapper->data;
Expand Down
1 change: 0 additions & 1 deletion core/src/vm/jsc/native_source_code_ios.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "core/vm/native_source_code.h"
#include "core/base/macros.h"

// clang-format off

namespace {
const uint8_t k_bootstrap[] = { 34,117,115,101,32,115,116,114,105,99,116,34,59,10,10,102,117,110,99,116,105,111,110,32,95,99,108,97,115,115,67,97,108,108,67,104,101,99,107,40,105,110,115,116,97,110,99,101,44,32,67,111,110,115,116,114,117,99,116,111,114,41,32,123,32,105,102,32,40,33,40,105,110,115,116,97,110,99,101,32,105,110,115,116,97,110,99,101,111,102,32,67,111,110,115,116,114,117,99,116,111,114,41,41,32,123,32,116,104,114,111,119,32,110,101,119,32,84,121,112,101,69,114,114,111,114,40,34,67,97,110,110,111,116,32,99,97,108,108,32,97,32,99,108,97,115,115,32,97,115,32,97,32,102,117,110,99,116,105,111,110,34,41,59,32,125,32,125,10,10,102,117,110,99,116,105,111,110,32,95,100,101,102,105,110,101,80,114,111,112,101,114,116,105,101,115,40,116,97,114,103,101,116,44,32,112,114,111,112,115,41,32,123,32,102,111,114,32,40,118,97,114,32,105,32,61,32,48,59,32,105,32,60,32,112,114,111,112,115,46,108,101,110,103,116,104,59,32,105,43,43,41,32,123,32,118,97,114,32,100,101,115,99,114,105,112,116,111,114,32,61,32,112,114,111,112,115,91,105,93,59,32,100,101,115,99,114,105,112,116,111,114,46,101,110,117,109,101,114,97,98,108,101,32,61,32,100,101,115,99,114,105,112,116,111,114,46,101,110,117,109,101,114,97,98,108,101,32,124,124,32,102,97,108,115,101,59,32,100,101,115,99,114,105,112,116,111,114,46,99,111,110,102,105,103,117,114,97,98,108,101,32,61,32,116,114,117,101,59,32,105,102,32,40,34,118,97,108,117,101,34,32,105,110,32,100,101,115,99,114,105,112,116,111,114,41,32,100,101,115,99,114,105,112,116,111,114,46,119,114,105,116,97,98,108,101,32,61,32,116,114,117,101,59,32,79,98,106,101,99,116,46,100,101,102,105,110,101,80,114,111,112,101,114,116,121,40,116,97,114,103,101,116,44,32,100,101,115,99,114,105,112,116,111,114,46,107,101,121,44,32,100,101,115,99,114,105,112,116,111,114,41,59,32,125,32,125,10,10,102,117,110,99,116,105,111,110,32,95,99,114,101,97,116,101,67,108,97,115,115,40,67,111,110,115,116,114,117,99,116,111,114,44,32,112,114,111,116,111,80,114,111,112,115,44,32,115,116,97,116,105,99,80,114,111,112,115,41,32,123,32,105,102,32,40,112,114,111,116,111,80,114,111,112,115,41,32,95,100,101,102,105,110,101,80,114,111,112,101,114,116,105,101,115,40,67,111,110,115,116,114,117,99,116,111,114,46,112,114,111,116,111,116,121,112,101,44,32,112,114,111,116,111,80,114,111,112,115,41,59,32,105,102,32,40,115,116,97,116,105,99,80,114,111,112,115,41,32,95,100,101,102,105,110,101,80,114,111,112,101,114,116,105,101,115,40,67,111,110,115,116,114,117,99,116,111,114,44,32,115,116,97,116,105,99,80,114,111,112,115,41,59,32,79,98,106,101,99,116,46,100,101,102,105,110,101,80,114,111,112,101,114,116,121,40,67,111,110,115,116,114,117,99,116,111,114,44,32,34,112,114,111,116,111,116,121,112,101,34,44,32,123,32,119,114,105,116,97,98,108,101,58,32,102,97,108,115,101,32,125,41,59,32,114,101,116,117,114,110,32,67,111,110,115,116,114,117,99,116,111,114,59,32,125,10,10,102,117,110,99,116,105,111,110,32,95,116,121,112,101,111,102,40,111,98,106,41,32,123,32,34,64,98,97,98,101,108,47,104,101,108,112,101,114,115,32,45,32,116,121,112,101,111,102,34,59,32,114,101,116,117,114,110,32,95,116,121,112,101,111,102,32,61,32,34,102,117,110,99,116,105,111,110,34,32,61,61,32,116,121,112,101,111,102,32,83,121,109,98,111,108,32,38,38,32,34,115,121,109,98,111,108,34,32,61,61,32,116,121,112,101,111,102,32,83,121,109,98,111,108,46,105,116,101,114,97,116,111,114,32,63,32,102,117,110,99,116,105,111,110,32,40,111,98,106,41,32,123,32,114,101,116,117,114,110,32,116,121,112,101,111,102,32,111,98,106,59,32,125,32,58,32,102,117,110,99,116,105,111,110,32,40,111,98,106,41,32,123,32,114,101,116,117,114,110,32,111,98,106,32,38,38,32,34,102,117,110,99,116,105,111,110,34,32,61,61,32,116,121,112,101,111,102,32,83,121,109,98,111,108,32,38,38,32,111,98,106,46,99,111,110,115,116,114,117,99,116,111,114,32,61,61,61,32,83,121,109,98,111,108,32,38,38,32,111,98,106,32,33,61,61,32,83,121,109,98,111,108,46,112,114,111,116,111,116,121,112,101,32,63,32,34,115,121,109,98,111,108,34,32,58,32,116,121,112,101,111,102,32,111,98,106,59,32,125,44,32,95,116,121,112,101,111,102,40,111,98,106,41,59,32,125,10,10,40,102,117,110,99,116,105,111,110,32,40,103,101,116,73,110,116,101,114,110,97,108,66,105,110,100,105,110,103,41,32,123,10,32,32,103,108,111,98,97,108,46,72,105,112,112,121,32,61,32,123,125,59,10,32,32,118,97,114,32,98,105,110,100,105,110,103,79,98,106,32,61,32,123,125,59,10,10,32,32,118,97,114,32,105,110,116,101,114,110,97,108,66,105,110,100,105,110,103,32,61,32,102,117,110,99,116,105,111,110,32,105,110,116,101,114,110,97,108,66,105,110,100,105,110,103,40,109,111,100,117,108,101,41,32,123,10,32,32,32,32,105,102,32,40,95,116,121,112,101,111,102,40,98,105,110,100,105,110,103,79,98,106,91,109,111,100,117,108,101,93,41,32,33,61,61,32,39,111,98,106,101,99,116,39,41,32,123,10,32,32,32,32,32,32,98,105,110,100,105,110,103,79,98,106,91,109,111,100,117,108,101,93,32,61,32,103,101,116,73,110,116,101,114,110,97,108,66,105,110,100,105,110,103,40,109,111,100,117,108,101,41,59,10,32,32,32,32,125,10,10,32,32,32,32,114,101,116,117,114,110,32,98,105,110,100,105,110,103,79,98,106,91,109,111,100,117,108,101,93,59,10,32,32,125,59,10,10,32,32,118,97,114,32,67,111,110,116,101,120,116,105,102,121,83,99,114,105,112,116,32,61,32,105,110,116,101,114,110,97,108,66,105,110,100,105,110,103,40,39,67,111,110,116,101,120,116,105,102,121,77,111,100,117,108,101,39,41,59,10,10,32,32,118,97,114,32,78,97,116,105,118,101,77,111,100,117,108,101,32,61,32,102,117,110,99,116,105,111,110,32,40,41,32,123,10,32,32,32,32,102,117,110,99,116,105,111,110,32,78,97,116,105,118,101,77,111,100,117,108,101,40,102,105,108,101,110,97,109,101,41,32,123,10,32,32,32,32,32,32,95,99,108,97,115,115,67,97,108,108,67,104,101,99,107,40,116,104,105,115,44,32,78,97,116,105,118,101,77,111,100,117,108,101,41,59,10,10,32,32,32,32,32,32,116,104,105,115,46,102,105,108,101,110,97,109,101,32,61,32,102,105,108,101,110,97,109,101,59,10,32,32,32,32,32,32,116,104,105,115,46,101,120,112,111,114,116,115,32,61,32,123,125,59,10,32,32,32,32,125,10,10,32,32,32,32,95,99,114,101,97,116,101,67,108,97,115,115,40,78,97,116,105,118,101,77,111,100,117,108,101,44,32,91,123,10,32,32,32,32,32,32,107,101,121,58,32,34,99,111,109,112,105,108,101,34,44,10,32,32,32,32,32,32,118,97,108,117,101,58,32,102,117,110,99,116,105,111,110,32,99,111,109,112,105,108,101,40,41,32,123,10,32,32,32,32,32,32,32,32,118,97,114,32,102,110,32,61,32,67,111,110,116,101,120,116,105,102,121,83,99,114,105,112,116,46,82,117,110,73,110,84,104,105,115,67,111,110,116,101,120,116,40,116,104,105,115,46,102,105,108,101,110,97,109,101,41,59,10,32,32,32,32,32,32,32,32,102,110,40,116,104,105,115,46,101,120,112,111,114,116,115,44,32,78,97,116,105,118,101,77,111,100,117,108,101,46,114,101,113,117,105,114,101,44,32,105,110,116,101,114,110,97,108,66,105,110,100,105,110,103,41,59,10,32,32,32,32,32,32,125,10,32,32,32,32,125,44,32,123,10,32,32,32,32,32,32,107,101,121,58,32,34,99,97,99,104,101,34,44,10,32,32,32,32,32,32,118,97,108,117,101,58,32,102,117,110,99,116,105,111,110,32,99,97,99,104,101,40,41,32,123,10,32,32,32,32,32,32,32,32,78,97,116,105,118,101,77,111,100,117,108,101,46,99,97,99,104,101,91,116,104,105,115,46,102,105,108,101,110,97,109,101,93,32,61,32,116,104,105,115,59,10,32,32,32,32,32,32,125,10,32,32,32,32,125,93,44,32,91,123,10,32,32,32,32,32,32,107,101,121,58,32,34,114,101,113,117,105,114,101,34,44,10,32,32,32,32,32,32,118,97,108,117,101,58,32,102,117,110,99,116,105,111,110,32,114,101,113,117,105,114,101,40,102,105,108,101,80,97,116,104,41,32,123,10,32,32,32,32,32,32,32,32,118,97,114,32,102,105,108,101,80,97,116,104,65,114,114,32,61,32,102,105,108,101,80,97,116,104,46,115,112,108,105,116,40,39,47,39,41,59,10,32,32,32,32,32,32,32,32,118,97,114,32,102,105,108,101,110,97,109,101,32,61,32,102,105,108,101,80,97,116,104,65,114,114,91,102,105,108,101,80,97,116,104,65,114,114,46,108,101,110,103,116,104,32,45,32,49,93,59,10,32,32,32,32,32,32,32,32,118,97,114,32,99,97,99,104,101,100,32,61,32,78,97,116,105,118,101,77,111,100,117,108,101,46,99,97,99,104,101,91,102,105,108,101,110,97,109,101,93,59,10,10,32,32,32,32,32,32,32,32,105,102,32,40,99,97,99,104,101,100,41,32,123,10,32,32,32,32,32,32,32,32,32,32,114,101,116,117,114,110,32,99,97,99,104,101,100,46,101,120,112,111,114,116,115,59,10,32,32,32,32,32,32,32,32,125,10,10,32,32,32,32,32,32,32,32,118,97,114,32,110,97,116,105,118,101,77,111,100,117,108,101,32,61,32,110,101,119,32,78,97,116,105,118,101,77,111,100,117,108,101,40,102,105,108,101,110,97,109,101,41,59,10,32,32,32,32,32,32,32,32,110,97,116,105,118,101,77,111,100,117,108,101,46,99,97,99,104,101,40,41,59,10,32,32,32,32,32,32,32,32,110,97,116,105,118,101,77,111,100,117,108,101,46,99,111,109,112,105,108,101,40,41,59,10,32,32,32,32,32,32,32,32,114,101,116,117,114,110,32,110,97,116,105,118,101,77,111,100,117,108,101,46,101,120,112,111,114,116,115,59,10,32,32,32,32,32,32,125,10,32,32,32,32,125,93,41,59,10,10,32,32,32,32,114,101,116,117,114,110,32,78,97,116,105,118,101,77,111,100,117,108,101,59,10,32,32,125,40,41,59,10,10,32,32,78,97,116,105,118,101,77,111,100,117,108,101,46,99,97,99,104,101,32,61,32,123,125,59,10,10,32,32,78,97,116,105,118,101,77,111,100,117,108,101,46,114,101,113,117,105,114,101,40,39,104,105,112,112,121,46,106,115,39,41,59,10,125,41,59,0 }; // NOLINT
Expand Down
65 changes: 37 additions & 28 deletions ios/sdk/base/HippyBatchedBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -630,8 +630,12 @@ - (void)stopLoadingWithError:(NSError *)error {
}

_loading = NO;
__weak HippyBatchedBridge *weakSelf = self;
[_javaScriptExecutor executeBlockOnJavaScriptQueue:^{
[self->_javaScriptExecutor invalidate];
HippyBatchedBridge *strongSelf = weakSelf;
if (strongSelf) {
[strongSelf->_javaScriptExecutor invalidate];
}
}];

[[NSNotificationCenter defaultCenter] postNotificationName:HippyJavaScriptDidFailToLoadNotification object:_parentBridge
Expand Down Expand Up @@ -714,22 +718,18 @@ - (void)dispatchBlock:(dispatch_block_t)block queue:(dispatch_queue_t)queue {
if (queue == HippyJSThread) {
// HippyProfileBeginFlowEvent();
HippyAssert(_javaScriptExecutor != nil, @"Need JS executor to schedule JS work");

__weak HippyBatchedBridge *weakSelf = self;
[_javaScriptExecutor executeBlockOnJavaScriptQueue:^{
// HippyProfileEndFlowEvent();

// HIPPY_PROFILE_BEGIN_EVENT(0, @"-[HippyBatchedBridge dispatchBlock", @{ @"loading": @(self.loading) });

@autoreleasepool {
if (self.loading) {
HippyAssert(self->_pendingCalls != nil, @"Can't add pending call, bridge is no longer loading");
[self->_pendingCalls addObject:block];
} else {
block();
}
HippyBatchedBridge *strongSelf = weakSelf;
if (!strongSelf) {
return;
}
if (strongSelf.loading) {
HippyAssert(strongSelf->_pendingCalls != nil, @"Can't add pending call, bridge is no longer loading");
[strongSelf->_pendingCalls addObject:block];
} else {
block();
}

// HIPPY_PROFILE_END_EVENT(HippyProfileTagAlways, @"");
}];
} else if (queue) {
dispatch_async(queue, block);
Expand Down Expand Up @@ -785,19 +785,24 @@ - (void)invalidate {

dispatch_group_notify(group, dispatch_get_main_queue(), ^{
[self->_displayLink invalidate];
__weak HippyBatchedBridge *weakSelf = self;
[self->_javaScriptExecutor executeBlockOnJavaScriptQueue:^{
std::lock_guard<std::mutex> lock(self->_moduleDataMutex);
self->_displayLink = nil;
[self->_javaScriptExecutor invalidate];
self->_javaScriptExecutor = nil;

self->_moduleDataByName = nil;
self->_moduleDataByID = nil;
self->_moduleClassesByID = nil;
self->_pendingCalls = nil;

if (self->_flowIDMap != NULL) {
CFRelease(self->_flowIDMap);
HippyBatchedBridge *strongSelf = weakSelf;
if (!strongSelf) {
return;
}
std::lock_guard<std::mutex> lock(strongSelf->_moduleDataMutex);
strongSelf->_displayLink = nil;
[strongSelf->_javaScriptExecutor invalidate];
strongSelf->_javaScriptExecutor = nil;

strongSelf->_moduleDataByName = nil;
strongSelf->_moduleDataByID = nil;
strongSelf->_moduleClassesByID = nil;
strongSelf->_pendingCalls = nil;

if (strongSelf->_flowIDMap != NULL) {
CFRelease(strongSelf->_flowIDMap);
}
}];
});
Expand Down Expand Up @@ -885,8 +890,12 @@ - (JSValue *)callFunctionOnModule:(NSString *)module
*/
- (void)_immediatelyCallTimer:(NSNumber *)timer {
HippyAssertJSThread();
__weak HippyBatchedBridge *weakSelf = self;
[_javaScriptExecutor executeAsyncBlockOnJavaScriptQueue:^{
[self _actuallyInvokeAndProcessModule:@"JSTimersExecution" method:@"callTimers" arguments:@[@[timer]]];
HippyBatchedBridge *strongSelf = weakSelf;
if (strongSelf) {
[strongSelf _actuallyInvokeAndProcessModule:@"JSTimersExecution" method:@"callTimers" arguments:@[@[timer]]];
}
}];
}

Expand Down
Loading

0 comments on commit 33dc927

Please sign in to comment.