• Stars
    star
    206
  • Rank 190,504 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 8 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Mobile Hybrid Framework Rexxar Web SDK

rexxar-web

Rexxar 是一个针对移动端的混合开发框架。现在支持 Android 和 iOS 平台。rexxar-web 是 Rexxar 的 Web 端实现,提供配合 Rexxar Container 运行的基础工具。

想要运行一个例子了解使用 Rexxar 开发页面的工作流程,直接查看简单的 example。如果要在 iOS/Android Container 查看,请至 rexxar-iosrexxar-android

Rexxar 简介

关于 Rexxar 的整体介绍,可以查看文档:Rexxar 简介

关于 Rexxar iOS,可以访问:https://github.com/douban/rexxar-ios

关于 Rexxar Android,可以访问:https://github.com/douban/rexxar-android

安装

$ npm install rexxar-web --save

使用

widgetMessenger

widgetMessenger 是一个消息组装器,分段传入参数构成消息体

let messenger = widgetMessenger('douban', 'rexxar-container')('widget/alert_dialog')

callbackListener

callbackListener 将注册给定的回调函数,并挂载到全局,用于客户端调用

let cbName = callbackListener('Rexxar.Widget.AlertDialog')('confirm')(() => {})

assemblePayload(obj[, base])

assemblePayload 是将一个对象转化成消息中的payload

let data = { 
  title: 'AlertDialog',
  callback: cbName,
}
let payload = assemblePayload(data)

dispatch(messenger)

dispatch 将由widgetMessenger组装好的消息分发给客户端

dispatch(messenger(payload))

rexxarFetch(input[, init])

rexxarFetch 是对 fetch 的包装,提供与 window.fetch 一样的接口和用法。值得注意的是,在使用 POST 时会有所限制,只允许 content-typeapplication/x-www-form-urlencoded 的请求。

import { rexxarFetch } from 'rexxar-web';

rexxarFetch('/request')
  .then(response => response.json())
  .then(data =>
    console.log('request succeeded with JSON response', data)
  )
  .catch(error =>
    console.log('request failed', error)
  )

getRexxarWidget(config)

Deprecated

配置 Widget 协议的 scheme 和 host,获取 RexxarWidget 基类,推荐使用继承的方式编写自己的组件。

import { getRexxarWidget } from 'rexxar-web';

const RexxarWidget = getRexxarWidget({
  scheme: 'douban',
  host: 'rexxar-container'
});

class Title extends RexxarWidget {
  constructor(title) {
    super('title');
    this.title = title;
  }
  show() {
    super.call({ title: this.title });
  }
}
let title = new Title('My Title');
title.show();

开发与部署

关于如何开发一个 Rexxar 页面,并进行调试,部署集成,请查看 example 目录。

Quick Start

安装

$ git clone https://github.com/douban/rexxar-web
$ cd rexxar-web/example
$ npm i

调试

$ gulp serve

gulp serve 启动调试服务器之后,你可以在浏览器中通过 http://localhost:8080/rexxar/demo.html?uri=douban://douban.com/rexxar_demo/ 这样的url来查看页面。

如果你需要 iOS/Android Container 访问调试服务器上的页面,则应该在 serve 的时候明确指定机器的ip。

$ gulp serve --ip 192.168.0.250

然后将 Container 中的 routes 地址改为 http://192.168.0.250:8080/routes.json 这样的地址。

部署

本地调试完成后,通过以下命令可以在 dist 目录下生成一系列打包后的资源:

$ gulp deploy

在这个例子中我们用 raw.githubusercontent.com 作为我们的静态资源存放地址,iOS/Android Container 通过访问 dist/routes.json 获取路由文件。当然你可以使用自己的CDN服务器来存放资源,并且可以根据需求定制自己的测试环境和线上环境。

ChangeLog

  • v0.2.0
    1. rexxarFetch 对于 iOS WKWebView 亦将 POST 转化成 GET 来处理,需要配合 rexxar-ios v0.3.0 及以上使用
    2. 新增 widgetMessenger, assemblePayload, callbackListener, dispatch
    3. 废弃 getRexxarWidget

Contributing

develop process

  1. develop on your branch
  2. run build via eslint
  3. test in example
  4. commit and pr

release process

  1. check build
  2. dump version to new one in package.json
  3. pr and merge into master
  4. add tag and write changelog
  5. npm publish

License

Rexxar is released under the MIT license. See LICENSE for details.

More Repositories

1

DOUAudioStreamer

A Core Audio based streaming audio player for iOS and macOS
Objective-C
2,768
star
2

dpark

Python clone of Spark, a MapReduce alike framework in Python
Python
2,691
star
3

code

[DEPRECATED]Douban CODE
CSS
1,811
star
4

beansdb

Archived, see GoBeansDB instead.
C
870
star
5

douban-client

Python client library for Douban APIs (OAuth 2.0)
Python
744
star
6

rexxar-android

Mobile Hybrid Framework Rexxar Android Container
Java
667
star
7

rexxar-ios

Mobile Hybrid Framework Rexxar iOS Container
Objective-C
578
star
8

FRDIntent

A framework for handle the call between view controllers in iOS
Swift
492
star
9

gobeansdb

Distributed object storage server from Douban Inc.
Go
451
star
10

libmc

Fast and light-weight memcached client for C++ / #python / #golang #libmc
C++
442
star
11

greenify

Make blocking C library work with gevent
C
427
star
12

ynm3k

UI Automation + YUItest driven acceptance tests that can be hooked into Jenkins
JavaScript
410
star
13

paracel

Distributed training framework with parameter server
C++
337
star
14

douban-objc-client

Objective-C client library for Douban APIs (OAuth 2.0)
Objective-C
254
star
15

beanseye

Proxy and monitor for beansdb in Go
Go
233
star
16

Kenshin

Kenshin: A time-series database alternative to Graphite Whisper with 40x improvement in IOPS
Python
206
star
17

tfmesos

Tensorflow in Docker on Mesos #tfmesos #tensorflow #mesos
Python
191
star
18

pymesos

A pure python implementation of Mesos scheduler and executor
Python
163
star
19

brownant

Brownant is a web data extracting framework.
Python
159
star
20

linguist

Language Savant, Python clone of github/linguist.
Python
153
star
21

graph-index

index of Graphite & Diamond
Python
129
star
22

CaoE

Kill all children processes when the parent dies
Python
101
star
23

douban-quixote

Douban's Quixote
Python
82
star
24

douban-utils

Douban's Utils
Python
59
star
25

python-libmemcached

DEPRECATED, use https://github.com/douban/libmc instead. python-libmemcached is a python extention for libmemcached
Python
57
star
26

PyCharlockHolmes

Character encoding detecting library for Python using ICU and libmagic.
Common Lisp
50
star
27

DOUSNSSharing

SNS OAuth 2 binding and sharing
Objective-C
47
star
28

ellen

Ellen is a wrapper of pygit2 and git command.
Python
41
star
29

Polymorph

Transform value of dictionary to property of Objective-C class, by using a `dynamic` like directive.
Objective-C
40
star
30

douban-sqlstore

Douban's MySQL lib.
Python
31
star
31

gpack

GIT Smart HTTP Server Rack Implementation, Python clone of https://github.com/schacon/grack
Python
30
star
32

douban-orz

The Missing Data Manager In Douban
Python
29
star
33

douban-mc

Douban's Memcached lib for python.
Python
27
star
34

charts

Helm charts from douban
Smarty
24
star
35

helpdesk

Yet another helpdesk based on multiple providers
Python
22
star
36

sina

A GIT Smart HTTP Server WSGI Implementation.
Python
21
star
37

sa-tools-core

Handy tools for sysadmin.
Python
18
star
38

graphite-kenshin

A plugin for using graphite-web with the kenshin-based storage backend.
Python
16
star
39

gobeansproxy

A proxy for GoBeansDB
Go
13
star
40

beansdbadmin

GoBeansDB Admin UI
Python
9
star
41

redarrow-rs

A command dispatcher to run executables remotely and safely.
Rust
6
star
42

MTURLProtocol

Multiple NSURLProtocol subclasses alternative solution.
Objective-C
4
star
43

python-libmagic

A wrapper for libmagic with static build.
Python
3
star
44

qiniu-exporter

Go
2
star
45

aliyun-exporter

Go
2
star
46

pyquicklz

C
1
star
47

upyun-exporter

Go
1
star
48

sa-tools-go

go version for sa-tools
Go
1
star