Skip to content

Commit

Permalink
Merge pull request #1 from alibaba/doc
Browse files Browse the repository at this point in the history
merge from alibaba/weex
  • Loading branch information
siqin authored Jul 8, 2016
2 parents 72e48c6 + b3d4293 commit 5a1ae3b
Show file tree
Hide file tree
Showing 328 changed files with 8,528 additions and 38,572 deletions.
6 changes: 5 additions & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
(Please ***REMOVE*** the following description before submiting)

0. It's ***RECOMMENDED*** to [submit PR](https://github.com/alibaba/weex/pulls) for typo, new demo or tiny bugfix.
0. If this's a ***BUG***, pls provide: course repetition, error/crash log, device model, OS version, App version (playground or other apps).
0. If this's a ***FEATURE***, pls provide: details, pseudo codes if necessary.

---

(请在***提交***前删除这段描述)

0. 我们***推荐***小问题直接[提 PR](https://github.com/alibaba/weex/pulls),如错别字、新 demo 或 bugfix。
0. 如果是 ***Bug***,请提供:复现步骤(推荐有截图)、error/crash log、设备型号、OS 版本、App 版本(playground 版本或自己的 app)。
0. 如果是***新需求***,请提供:详细描述、应用场景、适当的伪代码(如有)。
0. 如果是***新需求***,请提供:详细描述、应用场景、适当的伪代码(如有)。
4 changes: 4 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
(Please ***REMOVE*** the following description before submiting)

It's ***RECOMMENDED*** to submit typo fix, new demo and tiny bugfix to `dev` branch. New feature and other modifications can be submitted to "domain" branch including `ios`, `android`, `jsfm`, `html5`.

See [Branch Strategy](https://github.com/alibaba/weex/blob/dev/CONTRIBUTING.md#branch-management) for more detail.

---

(请在***提交***前删除这段描述)

错别字修改、新 demo、较小的 bugfix 都可以直接提到 `dev` 分支;新需求以及任何你不确定影响面的改动,请提交到对应“领域”的分支(`ios``android``jsfm``html5`)。

查看完整的[分支策略 (英文)](https://github.com/alibaba/weex/blob/dev/CONTRIBUTING.md#branch-management)
39 changes: 23 additions & 16 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,19 @@ Welcome to create [Pull Requests](https://github.com/alibaba/weex/compare) or op
```
master
dev <--- PR(hotfix/typo)
dev <--- PR(hotfix/typo/3rd-PR)
↑ PR
daily <--- CI
↑ merge/PR
{domain} <--- PR(feature/bugfix)
↑ merge/PR
{domain}-feature-{date}
```
Weex Branches

0. `dev`, `master` branch
0. `dev` is the stable developing branch,`master` is the latest (pre-)release branch.
0. [Github Release](https://help.github.com/articles/creating-releases/) is used to publish a (pre-)release version to `master` branch.
0. A hotfix or typo PR can be committed to `dev`.
0. `daily` branch
0. `domain` branches are merged to `daily` every day.
0. Weex CI is built to guarantee the stability of `daily`.
0. `{domain}` branch
0. `{domain}` is the stable developing branch for the specific domain including `android`, `ios`, `jsfm` and `html5`.
0. ***It's RECOMMENDED to commit feature or bugfix PR to `domain`***.
0. `master` branch
0. `master` is the latest (pre-)release branch.
0. `dev` branch
0. `dev` is the stable developing branch. [Github Release](https://help.github.com/articles/creating-releases/) is used to publish a (pre-)release version to `master` branch.
0. ***It's RECOMMENDED to commit hotfix (like typo) or feature PR to `dev`***.
0. `{domain}-feature-{date}` branch
0. The branch for a developing iteration, e.g. `android-feature-20160607` is an android developing iteration which is done at 2016.06.07.
0. The branch for a developing iteration, e.g. `android-feature-20160607` is an android developing iteration which is done at 2016.06.07. `{domain}` consists of `android`, `ios`, `jsfm` and `html5`.
0. **DO NOT commit any PR to such a branch**.

### Branch Name
Expand Down Expand Up @@ -74,3 +65,19 @@ for example:
## Pull Request

[Create Pull Requests](https://github.com/alibaba/weex/compare).

## Code Style Guide

### Objective-C

* Tabs for indentation(not spaces)
* `*` operator goes with the variable name (e.g. Type *variable;)
* Function definitions: place each brace on its own line.
* Other braces: place the open brace on the line preceding the code block; place the close brace on its own line.
* Use `#pragma marks` to categorize methods into functional groupings and protocol implementations
* Follow other guidelines on [GitHub Objective-C Style Guide](https://github.com/github/objective-c-style-guide)

### Java & Android

* Use [Google Java Style](https://google.github.io/styleguide/javaguide.html) as basic guidelines of java code.
* Follow [AOSP Code Style](https://source.android.com/source/code-style.html) for rest of android related code style.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Please ***INSTALL [Git for Windows](https://git-scm.com/download/win)*** and run

## Use Weex

* See [Tutorial](http://alibaba.github.io/weex/doc/tutorial.html).
* See [Weex Documentation](http://alibaba.github.io/weex/doc/) for more information.
* [Tutorial](http://alibaba.github.io/weex/doc/tutorial.html)
* Doc: [English](http://alibaba.github.io/weex/doc/), [中文](https://github.com/weexteam/article/wiki/Weex%E4%B8%AD%E6%96%87%E6%96%87%E6%A1%A3)

### Android

Expand All @@ -29,7 +29,7 @@ Please ***INSTALL [Git for Windows](https://git-scm.com/download/win)*** and run
0. Install [Android Environment](http://developer.android.com/training/basics/firstapp/index.html)
0. Run playground, In Android Studio
0. Open `android/playground`
0. In `app/java/com.alibaba.weex/WXMainActivity`, modify `CURRENT_IP` to your local IP
0. In `app/java/com.alibaba.weex/IndexActivity`, modify `CURRENT_IP` to your local IP
0. Click <img src="http://gtms04.alicdn.com/tps/i4/TB1wCcqMpXXXXakXpXX3G7tGXXX-34-44.png" height="16" > (`Run` button)
0. [Add an example](./examples/README.md#add-an-example)

Expand All @@ -42,7 +42,7 @@ Please ***INSTALL [Git for Windows](https://git-scm.com/download/win)*** and run
0. `./start`
0. Install [iOS Environment](https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppStoreDistributionTutorial/Setup/Setup.html)
0. Install [CocoaPods](https://guides.cocoapods.org/using/getting-started.html)
0. Run playground
0. Run playground
0. `cd ios/playground`
0. `pod install`
0. Open `WeexDemo.xcworkspace` in Xcode
Expand Down
13 changes: 5 additions & 8 deletions android/.gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
playground/.gradle/
playground/.idea/
playground/build/
playground/app/app.iml
playground/app/build/
playground/local.properties
playground/playground.iml
commons/build/
.gradle
.idea
local.properties
*iml
build
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ public void onDestroy() {
@Override
public void onViewCreated(WXSDKInstance wxsdkInstance, View view) {
if (mContainer != null) {
mContainer.removeAllViews();
mContainer.addView(view);
}
}
Expand All @@ -354,4 +355,4 @@ public void onViewCreated(WXSDKInstance wxsdkInstance, View view) {
public void onRefreshSuccess(WXSDKInstance wxsdkInstance, int i, int i1) {

}
}
}
19 changes: 14 additions & 5 deletions android/inspector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ Open your terminal then type `npm install -g weex-devtool` and run.Launch it jus

##### How to use on an android device or emulator

###### Taste of first debug with playground
If you are a green hand to the debug of weex, we recommend you to try your first debug with `playground`, what you need to do is just launch the playground and scan the QR code shown in the debug page which wound opened if the `devtools server` have been launched. after you scan the QR code, the web page will list your connected devices.

![devtools-main](https://img.alicdn.com/tps/TB13fwSKFXXXXXDaXXXXXXXXXXX-887-828.png "connecting (multiple) devices")


###### Enable devtools in your own app
Of course you can reuse the code of playground to build your own app, that is the simplest way to let your app's js code debuggable. On the other hand QR code is not necessary, if your review the source code you can draw a conclusion that QR CODE is just a way to set `devtools server` address. following those steps you can do the same thing.

- gradle dependency on inspector.
````
dependencies {
Expand All @@ -34,14 +43,14 @@ dependencies {
}
````

- set your remote bundle server ip.
- [**OPTION**] *set your remote bundle server ip.*

For example, in the playground it is in the `IndexActivity.java`, you need to change the value of `CURRENT_IP` in IndexActivity.java from `DEFAULT_IP` to a server ip like `"30.30.30.150"`:
For example, in the playground it is in the `IndexActivity.java`, you need to change the value of `DEFAULT_IP` in IndexActivity.java from `"your_current_IP"` to a server ip like `"30.30.30.150"`:
````
private static String CURRENT_IP = "30.30.30.150"; // "your_current_IP";
private static final String DEFAULT_IP = "30.30.30.150"; // "your_current_IP";
````

- enable network inspection.
- [**OPTION**] *enable network inspection.*
````
OkHttpClient client = new OkHttpClient();
client.networkInterceptors().add(new OkHttpInterceptor());
Expand All @@ -54,4 +63,4 @@ client.networkInterceptors().add(new OkHttpInterceptor());
1. you must launch your bundle server firstly. in your weex dir, run command "./start";
2. then launch your remote debug server. run command `weex-devtool`, chrome will open a web page show a simply guidance;
3. if your app launched, you will see a device list in the chrome web page opened by last step, each device item have two button, `open debugger` and `open inspector`;
4. once you click the button "open inspector" chrome will open a page show the inspector view, on the other side, click the button `open debugger` chrome will open a new page to show the debug view;
4. once you click the button "open inspector" chrome will open a page show the inspector view, on the other side, click the button `open debugger` chrome will open a new page to show the debug view;
2 changes: 1 addition & 1 deletion android/inspector/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.library'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
buildToolsVersion '23.0.2'

defaultConfig {
minSdkVersion 9
Expand Down
11 changes: 11 additions & 0 deletions android/inspector/debug.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,16 @@
{ "name": "callback", "type":"string"},
{ "name": "tasks", "type": "array", "items": { "$ref":"task"}}
]
},{
"name":"reload"
},{
"name":"registerDevice",
"parameters":[
{ "name": "name", "type":"string"},
{ "name": "model", "type":"string"},
{ "name": "weexVersion", "type": "string"},
{ "name": "platform", "type":"string"},
{ "name": "deviceId", "type":"string"}
]
}]
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.taobao.weex.bridge.WXJSObject;
import com.taobao.weex.bridge.WXParams;
import com.taobao.weex.common.IWXBridge;
import com.taobao.weex.common.IWXDebugProxy;
import com.taobao.weex.devtools.websocket.SimpleSession;

import java.util.ArrayList;
Expand All @@ -27,7 +28,7 @@ public class DebugBridge implements IWXBridge {
private Object mLock = new Object();
private WXBridgeManager mJsManager;
private SimpleSession mSession;
private MyBroadcastReceiver mReceiver;
private ConnectionBroadcastReceiver mReceiver;

private DebugBridge() {

Expand Down Expand Up @@ -69,24 +70,47 @@ public int initFramework(String framework, WXParams params) {
unregisterBroadcastReceiver();

if (mSession != null && mSession.isOpen()) {
mSession.sendText(getInitFrameworkMessage(framework));
mSession.sendText(getInitFrameworkMessage(framework, params));
return 1;
}

return 0;
}

private String getInitFrameworkMessage(String framework) {
private String getInitFrameworkMessage(String framework, WXParams params) {
Map<String, Object> func = new HashMap<>();
func.put("source", framework);
func.put(WXDebugConstants.PARAM_JS_SOURCE, framework);
if (params != null) {
Map<String, Object> environmentMap = getEnvironmentMap(params);
if (environmentMap != null && environmentMap.size() > 0) {
Map<String, Object> wxEnvironment = new HashMap<>();
wxEnvironment.put(WXDebugConstants.ENV_WX_ENVIRONMENT, environmentMap);
func.put(WXDebugConstants.PARAM_INIT_ENV, wxEnvironment);
}
}

Map<String, Object> map = new HashMap<>();
map.put("method", "WxDebug.initJSRuntime");
map.put("params", func);
map.put(WXDebugConstants.METHOD, WXDebugConstants.METHOD_INIT_RUNTIME);
map.put(WXDebugConstants.PARAMS, func);

return JSON.toJSONString(map);
}

private Map<String, Object> getEnvironmentMap(WXParams params) {
Map<String, Object> environment = new HashMap<>();
environment.put(WXDebugConstants.ENV_APP_NAME, params.getAppName());
environment.put(WXDebugConstants.ENV_APP_VERSION, params.getAppVersion());
environment.put(WXDebugConstants.ENV_PLATFORM, params.getPlatform());
environment.put(WXDebugConstants.ENV_OS_VERSION, params.getOsVersion());
environment.put(WXDebugConstants.ENV_LOG_LEVEL, params.getLogLevel());
environment.put(WXDebugConstants.ENV_WEEX_VERSION, params.getWeexVersion());
environment.put(WXDebugConstants.ENV_DEVICE_MODEL, params.getDeviceModel());
environment.put(WXDebugConstants.ENV_INFO_COLLECT, params.getShouldInfoCollect());
environment.put(WXDebugConstants.ENV_DEVICE_WIDTH, params.getDeviceWidth());
environment.put(WXDebugConstants.ENV_DEVICE_HEIGHT, params.getDeviceHeight());
return environment;
}

@Override
public int execJS(String instanceId, String namespace, String function, WXJSObject[] args) {
// if (!mInit || (TextUtils.isEmpty(instanceId) && !WXBridgeManager.METHOD_REGISTER_MODULES.equals(function))
Expand All @@ -105,13 +129,13 @@ public int execJS(String instanceId, String namespace, String function, WXJSObje
}

Map<String, Object> func = new HashMap<>();
func.put("method", function);
func.put("args", array);
func.put(WXDebugConstants.METHOD, function);
func.put(WXDebugConstants.ARGS, array);

Log.v(TAG, "callJS: function is " + function + ", args " + array);
Map<String, Object> map = new HashMap<>();
map.put("method", "WxDebug.callJS");
map.put("params", func);
map.put(WXDebugConstants.METHOD, WXDebugConstants.METHOD_CALL_JS);
map.put(WXDebugConstants.PARAMS, func);
if (mSession != null && mSession.isOpen()) {
mSession.sendText(JSON.toJSONString(map));
}
Expand All @@ -120,9 +144,11 @@ public int execJS(String instanceId, String namespace, String function, WXJSObje
}

@Override
public void callNative(String instanceId, String tasks, String callback) {
public int callNative(String instanceId, String tasks, String callback) {
if (mJsManager != null) {
mJsManager.callNative(instanceId, tasks, callback);
return mJsManager.callNative(instanceId, tasks, callback);
}else{
return WXBridgeManager.INSTANCE_RENDERING_ERROR;
}
}

Expand All @@ -133,15 +159,15 @@ public void reportJSException(String instanceId, String func, String exception)
}
}

public class MyBroadcastReceiver extends BroadcastReceiver {
public class ConnectionBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (DebugServerProxy.ACTION_DEBUG_SERVER_CONNECTED.equals(intent.getAction())) {
if (IWXDebugProxy.ACTION_DEBUG_SERVER_CONNECTED.equals(intent.getAction())) {
Log.v(TAG, "connect to debug server success");
synchronized (mLock) {
mLock.notify();
}
} else if (DebugServerProxy.ACTION_DEBUG_SERVER_CONNECT_FAILED.equals(intent.getAction())) {
} else if (IWXDebugProxy.ACTION_DEBUG_SERVER_CONNECT_FAILED.equals(intent.getAction())) {
Log.v(TAG, "connect to debug server failed");
synchronized (mLock) {
mLock.notify();
Expand All @@ -151,10 +177,10 @@ public void onReceive(Context context, Intent intent) {
}

private void registerBroadcastReceiver() {
mReceiver = new MyBroadcastReceiver();
mReceiver = new ConnectionBroadcastReceiver();
IntentFilter filter = new IntentFilter();
filter.addAction(DebugServerProxy.ACTION_DEBUG_SERVER_CONNECTED);
filter.addAction(DebugServerProxy.ACTION_DEBUG_SERVER_CONNECT_FAILED);
filter.addAction(IWXDebugProxy.ACTION_DEBUG_SERVER_CONNECTED);
filter.addAction(IWXDebugProxy.ACTION_DEBUG_SERVER_CONNECT_FAILED);
WXEnvironment.getApplication().registerReceiver(mReceiver, filter);
}

Expand Down
Loading

0 comments on commit 5a1ae3b

Please sign in to comment.