Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
[WEEX-659][core][eagle] support more feature in parser (#1749)
Browse files Browse the repository at this point in the history
* [iOS] remove render_document.cpp from sdk

* [core] bugfix ' ' url_encode =>  '%20'

* [core] bugfix supporting function varying parameter

* [core] bugfix add utf8 decode for string tokenizer parsing

* [core] data_render output error log

* [core] fix event invalid in opcode

* [core] opcode supprot big endian

* [core] modify int to int32_t and unsigned to u_int32_t

* [core] add argc in opcode

* Print performance log in perf mode

* Catch Throwable to avoid huawei 500 boradcast crash

* Fix json class not  found crash

* fix npe

* [core]  __registerModules deprecated in sversion 5.8 + __requireModule supporting in sversion 5.8 +

* fix image strategy memory leak

* add function args for children function closure var implementation

* bugfix c function return nil or undefined

* bugfix argc param error

* [core]  add exec state binary implement

* [data_render] add support for regex

* [core] develop exec state section decoding and encoding implementation

* [core] bugfix dom diff for adding node to root render object

* [core] bugfix exec state decoding error

* [core] exec state encoding and decoding finally complete

* [core] fixed build error

* [core] bugfix encoding and decoding value ref error, and running closure OK

* [core] decrease constants value encoding file size

* [core] add bit reader and writer, adaptation for linux builder

* [core] adp linux builder

* [data-render] 修复Android编译环境

* [core] fix linux builder

* [core] add encoder compatible version

* [core] sdk version modify for defines

* [core] fix build on linux

* [core] encoding and decoding bits stream OK

* [core] remove debug code

* [core] fix linux header build

* [core] remove debug code

* [core] add compile error for line and col

* [core] supporting jsx element ...spread property

* [core] compile supporting arrow function with no args

* * [Android] Change NestedInstance in WXEmbed to protected for sub-class to override.

* [core] add typeof defines

* reboot jsc engine if there is no view add to container after 5s

* Change default timeout to public

* [core] bugfix a && b && c or a || b || c,   json parsing failed return  undefined, add op typeof

* Set reboot jsengine switch on

* [data-render] 增加对switch语句的支持

* [core] modify new expression, add args for new expression

* [core] add new expression constractor

* If context is not wxactivity, throw a exception to this instance

* [core] add OP_CONSTRUCTOR after OP_NEW

* [core] add console class function

* [data-render] console support in android

* [core] restore code

* [core] add class static member supporting, WeexSDK supporting *.wlasm for weex lite

* [core] modify WL_RENDER render  option for weex lite

* [core] modify WLASM_RENDER for weex lite render option

* [core] modify args length as Andriod

* [data_render] window.open support

* [core] modify WeexSDK building file

* [data-render] try catch parse, codegen only support try block and finally block

* [core] modify header file

* [core] add event supporting for function instance

* [core] bugfix crash by delete class twice

* [data-render] renderByUrl support wlasm

* [data_render] update so

* [data_render] fix arrow function parse error

* [core] supporting jsx props parse Token::SUB

* [core] supporting  return add '(' ')'

* [core] supporting array.map

* [data_render] math support

* [core] bugfix console.log string can't show

* [core] bugfix vue json binary encoding error,  add section data to store the array and table
  • Loading branch information
yxping authored and YorkShen committed Nov 13, 2018
1 parent ded64a3 commit 46603bf
Show file tree
Hide file tree
Showing 84 changed files with 7,149 additions and 1,765 deletions.
105 changes: 84 additions & 21 deletions android/playground/app/src/main/assets/lite_template/case.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,72 @@
/* eslint-disable react/react-in-jsx-scope */
/* global __weex_data__, print, createElement */

try{
console.log("abc in try");
} catch(err) {
console.log("err");
} finally{
console.log("finally");
}

var a= /(a.)/g;
var b = a.exec('abc,aac, ssa2, dda');
console.log(b);

console.log('aabccbddBc'.match(/(bss.)/g));

console.log("ceil");
console.log(Math.ceil(0.95)," == 1");
console.log(Math.ceil(4)," == 4");
console.log(Math.ceil(7.004)," == 8");
console.log(Math.ceil(-0.95)," == -0");
console.log(Math.ceil(-4)," == -4");
console.log(Math.ceil(-7.004)," == -7");

console.log("floor");
console.log(Math.floor( 45.95)," == 45");
console.log(Math.floor( 45.05)," == 45");
console.log(Math.floor( 4 )," == 4");
console.log(Math.floor(-45.05)," == -46");
console.log(Math.floor(-45.95)," == -46");

console.log("random");
console.log(Math.random());
console.log(Math.random());
console.log(Math.random());
console.log(Math.random());

console.log("max");
console.log(Math.max(1,2,3)," == 3");
console.log(Math.max(1,2.2, 4.2), "== 4.2");
console.log(Math.max(1,"a"),"== null");
console.log(Math.max(),"== INT_MIN");

console.log("min");
console.log(Math.min(1,2,3)," == 1");
console.log(Math.min(0.5,2.2, 4), "== 0.5");
console.log(Math.min(1,"a"),"== null");
console.log(Math.min(),"== INT_MAX");

var a = 3;

console.log('start');
switch(a){
case 1:
console.log('switch 1');
break;
case 2:
console.log('switch 2');
break;
default:
console.log('default branch');
}
console.log('end');
class Component {
constructor(props) {
this.props = props;
}

setState(newData) {
this.state = { ...this.state,
...newData
Expand All @@ -20,7 +82,7 @@ var nativeModules = {};
const registerModule = moduleName => {
var sourceKeys = Object.keys(moduleName);
var key;

for (var i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
nativeModules[key] = moduleName[key];
Expand All @@ -46,12 +108,12 @@ const require = name => {
loop(methods[i]);
}
}
log("register",methods);
console.log("register",methods);
return target;
};

const MODULE_NAME_PREFIX = '@weex-module/';

if (name.split(MODULE_NAME_PREFIX).length > 1) {
const weexModuleName = name.split(MODULE_NAME_PREFIX)[1];
return requireModule(weexModuleName);
Expand Down Expand Up @@ -150,12 +212,12 @@ class TipTag extends Component {
super(props);
}
_onClick = e => {
log("click go");
console.log("click go");
let searchParams = {};
if (this.props.data.q) {
searchParams.q = this.props.data.q;
}

if (this.props.data.params && this.props.data.params.length > 0) {
this.props.data.params.forEach(item => {
if (item.key) {
Expand All @@ -165,22 +227,22 @@ class TipTag extends Component {
}
if (this.props.tiptype && this.props.tiptype == 'voice_smarttips') {
searchParams['voiceFrom'] = '1';
log("se go");
console.log("se go");
searchEvent.searchOption("searchOption", {
params: searchParams
});
} else {
log("se go2");
console.log("se go2");
searchEvent.search("search", {
params: searchParams
});
}
};

render() {
let data = this.props.data;
let tagStyle = styles.tag;

if (!this.props.isListMode) {
tagStyle = { ...styles.tag,
marginLeft: 5.5,
Expand All @@ -193,7 +255,7 @@ class TipTag extends Component {
<Text style={styles.tagText}>{data.show}</Text>
</View>;
}

}

const _tiptag_export = {
Expand All @@ -205,23 +267,23 @@ const TipTag_import_default_from__WidgetInWFStyle__tiptag = _tiptag_export.defau
const WidgetInWFStyle = props => {
let tips = props.tips,
tiptype = props.tiptype;

if (!tips || tips.length === 0) {
return null;
}

if (tips.length > 8) {
tips = tips.slice(0, 8);
}

let wfTitle = <View style={waterfallStyles.wfTitle}>
<View style={waterfallStyles.wfDivideLine} />
<Text style={waterfallStyles.titleText}>{props.topic || '相关搜索'}</Text>
<View style={waterfallStyles.wfDivideLine} />
</View>;
let wfLines = [];
let tipLength = tips.length;

function createWfLine(leftTip, rightTip) {
let tag1 = <TipTag_import_default_from__WidgetInWFStyle__tiptag data={leftTip} isListMode={false} tiptype={tiptype} />;
let tag2 = rightTip ? <TipTag_import_default_from__WidgetInWFStyle__tiptag data={rightTip} isListMode={false} tiptype={tiptype} /> : null;
Expand Down Expand Up @@ -309,11 +371,11 @@ const WidgetInListStyle = props => {
if (!tips || tips.length === 0) {
return null;
}

if (tips.length > 8) {
tips = tips.slice(0, 8);
}

const listTitle = <View style={listStyles.listTitle}>
<View style={listStyles.divideLine} />
<Text style={listStyles.titleText}>{props.topic || '相关搜索'}</Text>
Expand All @@ -327,7 +389,7 @@ const WidgetInListStyle = props => {
firstLineTips.push(tipTag);
} else {
const firstLineCount = parseInt(tips.length / 2, 10) + tips.length % 2;

if (index < firstLineCount) {
firstLineTips.push(tipTag);
} else if (index < 8) {
Expand Down Expand Up @@ -371,7 +433,7 @@ class Widget extends Component {
return <View style={{ ...defaultStyle__lib.container
}}>{content}</View>;
}

}

const _lib_export = {
Expand Down Expand Up @@ -400,7 +462,8 @@ class Segment extends Component {
<Widget_import_default_from___lib {...data} />
</View>;
}

}

render(<Segment />);

Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,13 @@ private void loadWXfromService(final String url) {
public void onSuccess(WXHttpTask task) {
Log.i(TAG, "into--[http:onSuccess] url:" + url);
try {
Uri uri = Uri.parse(url);
mConfigMap.put("bundleUrl", url);
mInstance.render(TAG, new String(task.response.data, "utf-8"), mConfigMap, null, WXRenderStrategy.APPEND_ASYNC);
if (uri.getPath().endsWith(".wlasm")){
mInstance.render(TAG, task.response.data, mConfigMap, null);
} else {
mInstance.render(TAG, new String(task.response.data, "utf-8"), mConfigMap, null, WXRenderStrategy.APPEND_ASYNC);
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
Expand Down
2 changes: 1 addition & 1 deletion android/sdk/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=http://gw.alicdn.com/bao/uploaded/LB1J5WLJVXXXXcMXpXXXXXXXXXX.zip
Empty file modified android/sdk/libs/armeabi-v7a/libweexcore.so
100644 → 100755
Empty file.
Empty file modified android/sdk/libs/armeabi/libweexcore.so
100644 → 100755
Empty file.
Binary file modified android/sdk/libs/x86/libweexcore.so
100644 → 100755
Binary file not shown.
60 changes: 55 additions & 5 deletions android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
import java.util.PriorityQueue;
import java.util.concurrent.ConcurrentHashMap;

import static com.taobao.weex.common.WXErrorCode.WX_ERR_RELOAD_PAGE;
import static com.taobao.weex.http.WXHttpUtil.KEY_USER_AGENT;


Expand Down Expand Up @@ -127,6 +128,8 @@ public class WXSDKInstance implements IWXActivityStateListener,View.OnLayoutChan
private String mBundleUrl = "";
public static String requestUrl = "requestUrl";
private boolean isDestroy=false;
private boolean hasException = false;
private boolean isRenderSuccess = false;
private Map<String,Serializable> mUserTrackParams;
private NativeInvokeHelper mNativeInvokeHelper;
private boolean isCommit=false;
Expand Down Expand Up @@ -705,13 +708,43 @@ private void renderInternal(String pageName,

WXSDKManager.getInstance().createInstance(this, template, renderOptions, jsonInitData);
mRendered = true;


if(WXBridgeManager.getInstance().isIsRebootJscWhenWhiteScreen()) {
WXSDKManager.getInstance().postOnUiThread(new Runnable() {
@Override
public void run() {
if(isDestroy || hasException || isRenderSuccess) {
return;
}

View containerView = getContainerView();
if(containerView instanceof ViewGroup) {
if(0 == ((ViewGroup) containerView).getChildCount()) {
boolean isWxActivity = false;
if(mContext != null && mContext.getClass() != null) {
String name = mContext.getClass().getName();
if(!TextUtils.isEmpty(name)) {
isWxActivity = name.contains("WXActivity");
}
}

if(!isWxActivity) {
onJSException(String.valueOf(WX_ERR_RELOAD_PAGE),"jsc reboot","jsc reboot");
}
WXBridgeManager.getInstance().callReportCrashReloadPage(mInstanceId, null);
}
}
}
}, WXBridgeManager.getInstance().getRebootJscTimeout());
}
}

private void renderByUrlInternal(String pageName,
final String url,
Map<String, Object> options,
final String jsonInitData,
final WXRenderStrategy flag) {
WXRenderStrategy flag) {

ensureRenderArchor();
pageName = wrapPageName(pageName, url);
Expand Down Expand Up @@ -740,6 +773,16 @@ private void renderByUrlInternal(String pageName,
return;
}

boolean is_wlasm = false;
if (uri != null && uri.getPath()!=null) {
if(uri.getPath().endsWith(".wlasm")){
is_wlasm = true;
}
}
if (is_wlasm){
flag = WXRenderStrategy.DATA_RENDER_BINARY;
}

IWXHttpAdapter adapter = WXSDKManager.getInstance().getIWXHttpAdapter();

WXRequest wxRequest = new WXRequest();
Expand Down Expand Up @@ -1017,9 +1060,10 @@ public void onActivityCreate() {
mGlobalEventReceiver=new WXGlobalEventReceiver(this);
try {
getContext().registerReceiver(mGlobalEventReceiver, new IntentFilter(WXGlobalEventReceiver.EVENT_ACTION));
} catch (Exception e) {
} catch (Throwable e) {
// Huawei may throw a exception if register more than 500 BroadcastReceivers
WXLogUtils.e(e.getMessage());
mGlobalEventReceiver = null;
}

}
Expand Down Expand Up @@ -1265,6 +1309,7 @@ public void runOnUiThread(Runnable action) {
}

public void onRenderSuccess(final int width, final int height) {
isRenderSuccess = true;
if (!isNewFsEnd){
getApmForInstance().arriveNewFsRenderTime();
}
Expand Down Expand Up @@ -1298,7 +1343,7 @@ public void onRenderSuccess(final int width, final int height) {

WXLogUtils.d(WXLogUtils.WEEX_PERF_TAG, mWXPerformance.toString());
}
if(!WXEnvironment.isApkDebugable()){
if(WXEnvironment.isPerf()){
WXLogUtils.e("weex_perf",mWXPerformance.getPerfData());
}
}
Expand Down Expand Up @@ -1365,6 +1410,7 @@ public void run() {

public void onJSException(final String errCode, final String function, final String exception) {
getExceptionRecorder().recordReportErrorMsg("["+errCode+","+function+","+exception+"]");
hasException = true;
if (mRenderListener != null && mContext != null) {
runOnUiThread(new Runnable() {

Expand Down Expand Up @@ -2010,8 +2056,12 @@ public void onHttpFinish(WXResponse response) {
String wxErrorCode = WXInstanceApm.VALUE_ERROR_CODE_DEFAULT;
if (response!=null && response.originalData!=null && TextUtils.equals("200", response.statusCode)) {
mApmForInstance.onStage(WXInstanceApm.KEY_PAGE_STAGES_DOWN_BUNDLE_END);
String template = new String(response.originalData);
render(pageName, template, options, jsonInitData, flag);
if (flag==WXRenderStrategy.DATA_RENDER_BINARY){
render(pageName, response.originalData, options, jsonInitData);
} else {
String template = new String(response.originalData);
render(pageName, template, options, jsonInitData, flag);
}

// check content-type
} else if (TextUtils.equals(WXErrorCode.WX_DEGRAD_ERR_BUNDLE_CONTENTTYPE_ERROR.getErrorCode(),
Expand Down

0 comments on commit 46603bf

Please sign in to comment.