{"_id":"@duozhuayu/rexxar-web","_rev":"1-80a713bbcb6e2c2aadec53e53b0575f3","name":"@duozhuayu/rexxar-web","dist-tags":{"latest":"0.2.2"},"versions":{"0.2.2":{"name":"@duozhuayu/rexxar-web","version":"0.2.2","description":"Rexxar Web","main":"./lib/index.js","scripts":{"eslint":"eslint src","build":"babel src -d lib","test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/douban/rexxar-web.git"},"author":"","license":"ISC","devDependencies":{"babel-cli":"^6.11.4","babel-plugin-transform-object-rest-spread":"^6.16.0","babel-preset-es2015":"^6.13.2","eslint":"^3.6.1"},"peerDependencies":{"whatwg-fetch":"^3.0.0"},"gitHead":"ca756ae82608130f3303cc8057413fa6c9fbe16f","bugs":{"url":"https://github.com/douban/rexxar-web/issues"},"homepage":"https://github.com/douban/rexxar-web#readme","_id":"@duozhuayu/rexxar-web@0.2.2","_npmVersion":"6.4.1","_nodeVersion":"8.16.0","_npmUser":{"name":"raffyli","email":"lijunliang@duozhuayu.net"},"dist":{"integrity":"sha512-ona4nTliwwk1l2pEEgFIn96oDxHpktPgU0fJsK2InF4ZW6HfFVkt7cszi5Bj4ZKtZI0Vhshbyz+OdJkvapkd+Q==","shasum":"686718556bd5d22cd4208a7647c30281fb61ff97","tarball":"https://registry.npmjs.org/@duozhuayu/rexxar-web/-/rexxar-web-0.2.2.tgz","fileCount":63,"unpackedSize":269088,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdSk4rCRA9TVsSAnZWagAApoYQAJjTx1bVBH9qEPIl2v+3\n5lRH6aitmk8HF814iqbW8SrUtg3EHfhPBSA8L+lV2pihf7tZbQ+FCoVaaLLn\naAJwhQgC62BOdd2bloKlmAuFAPMuX2RzVKQaPv5Jxjnh0eEHITzth4enYLzt\nGgvNR94eVtwV66Y3oXkNqm06YZweMEBuhxEaLc4h+kot3PBlDIHhE3/CXkkT\nSW7Gx18yD9wiXjluHJp/knw75Vrkxlk8gba7hCTwwCmej5tTEyEpN8DFVUOY\npvcCx8QFdMwdStrxkrXkgxxA7Yd26or3AyYU/LERwcbQ+sdjWA0LVlH2eukr\nFi4blUXm2VVDjHWrVuh6BOybRtM5NUhhgIBu44MG5ijOgxg0A1EPekmFGWFb\n8wER0Em2dp/Vfb+MVH6B6teEs8JiSAGiCDYdri9xIxHF8YYQK07e8L/uSDeN\nWVPoBggVfTaI8q9glNZll3vG7bW8TgFsXyX4lYfz8L8rs6o52M0wd9+KNoGe\nhUER7aMRvObr+filYTPQThcLosUay2YaFrVgylAwZObJtoFU8PYSqEku4FrB\nIYasRHzBbaM+5wsVIXXCDgt1RFbQQ23919DTJm1v2n/AmmgFCTRzG3J3i+u+\nXebXlT0qbk63Lh5reC10OL+O6f68Ki0YYl7FgPnuKVzJylUjVuGSv1t8rlbk\n4buS\r\n=XH9u\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDSW71CbgCHzMFP6kb3NFAjmat+6Mc0WXq39Wsajj515AIhAMWI2B+z+0acUJEqT5LvmaDJqcTVyholxQ/TdU588MFR"}]},"maintainers":[{"name":"chaoqiang","email":"zhuchaoqiang@duozhuayu.net"},{"name":"raffyli","email":"lijunliang@duozhuayu.net"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rexxar-web_0.2.2_1565150762783_0.9710360833588378"},"_hasShrinkwrap":false}},"time":{"created":"2019-08-07T04:06:02.783Z","0.2.2":"2019-08-07T04:06:02.954Z","modified":"2022-04-05T06:09:00.533Z"},"maintainers":[{"name":"chaoqiang","email":"zhuchaoqiang@duozhuayu.net"},{"name":"raffyli","email":"lijunliang@duozhuayu.net"}],"description":"Rexxar Web","homepage":"https://github.com/douban/rexxar-web#readme","repository":{"type":"git","url":"git+https://github.com/douban/rexxar-web.git"},"bugs":{"url":"https://github.com/douban/rexxar-web/issues"},"license":"ISC","readme":"# rexxar-web\n\nRexxar 是一个针对移动端的混合开发框架。现在支持 Android 和 iOS 平台。`rexxar-web` 是 Rexxar 的 Web 端实现，提供配合 Rexxar Container 运行的基础工具。\n\n想要运行一个例子了解使用 Rexxar 开发页面的工作流程，直接查看简单的 [example](/example)。如果要在 iOS/Android Container 查看，请至 [rexxar-ios](https://github.com/douban/rexxar-ios) 或 [rexxar-android](https://github.com/douban/rexxar-android)。\n\n## Rexxar 简介\n\n关于 Rexxar 的整体介绍，可以查看文档：[Rexxar 简介](http://lincode.github.io/Rexxar-OpenSource)。\n\n关于 Rexxar iOS，可以访问：[https://github.com/douban/rexxar-ios](https://github.com/douban/rexxar-ios)。\n\n关于 Rexxar Android，可以访问：[https://github.com/douban/rexxar-android](https://github.com/douban/rexxar-android)。\n\n## 安装\n\n```bash\n$ npm install rexxar-web --save\n```\n\n## 使用\n\n### widgetMessenger\n\n`widgetMessenger` 是一个消息组装器，分段传入参数构成消息体\n\n```js\nlet messenger = widgetMessenger('douban', 'rexxar-container')('widget/alert_dialog')\n```\n\n### callbackListener\n\n`callbackListener` 将注册给定的回调函数，并挂载到全局，用于客户端调用\n\n```js\nlet cbName = callbackListener('Rexxar.Widget.AlertDialog')('confirm')(() => {})\n```\n\n### assemblePayload(obj[, base])\n\n`assemblePayload` 是将一个对象转化成消息中的payload\n\n```js\nlet data = { \n  title: 'AlertDialog',\n  callback: cbName,\n}\nlet payload = assemblePayload(data)\n```\n\n### dispatch(messenger)\n\n`dispatch` 将由widgetMessenger组装好的消息分发给客户端\n\n```js\ndispatch(messenger(payload))\n```\n\n### rexxarFetch(input[, init])\n\n`rexxarFetch` 是对 [fetch](https://github.com/github/fetch) 的包装，提供与 [window.fetch](https://fetch.spec.whatwg.org/) 一样的接口和用法。值得注意的是，在使用 POST 时会有所限制，只允许 `content-type` 为 `application/x-www-form-urlencoded` 的请求。\n\n```js\nimport { rexxarFetch } from 'rexxar-web';\n\nrexxarFetch('/request')\n  .then(response => response.json())\n  .then(data =>\n    console.log('request succeeded with JSON response', data)\n  )\n  .catch(error =>\n    console.log('request failed', error)\n  )\n```\n\n### getRexxarWidget(config)\n\n**Deprecated**\n\n配置 Widget 协议的 scheme 和 host，获取 RexxarWidget 基类，推荐使用继承的方式编写自己的组件。\n\n```js\nimport { getRexxarWidget } from 'rexxar-web';\n\nconst RexxarWidget = getRexxarWidget({\n  scheme: 'douban',\n  host: 'rexxar-container'\n});\n\nclass Title extends RexxarWidget {\n  constructor(title) {\n    super('title');\n    this.title = title;\n  }\n  show() {\n    super.call({ title: this.title });\n  }\n}\nlet title = new Title('My Title');\ntitle.show();\n```\n\n## 开发与部署\n\n关于如何开发一个 Rexxar 页面，并进行调试，部署集成，请查看 [example](/example) 目录。\n\n### Quick Start\n\n#### 安装\n\n```bash\n$ git clone https://github.com/douban/rexxar-web\n$ cd rexxar-web/example\n$ npm i\n```\n\n#### 调试\n\n```bash\n$ gulp serve\n```\ngulp serve 启动调试服务器之后，你可以在浏览器中通过  `http://localhost:8080/rexxar/demo.html?uri=douban://douban.com/rexxar_demo/` 这样的url来查看页面。\n\n如果你需要 iOS/Android Container 访问调试服务器上的页面，则应该在 `serve` 的时候明确指定机器的ip。\n```bash\n$ gulp serve --ip 192.168.0.250\n```\n然后将 Container 中的 routes 地址改为 `http://192.168.0.250:8080/routes.json` 这样的地址。\n\n#### 部署\n\n本地调试完成后，通过以下命令可以在 `dist` 目录下生成一系列打包后的资源：\n```bash\n$ gulp deploy\n```\n在这个例子中我们用 `raw.githubusercontent.com` 作为我们的静态资源存放地址，iOS/Android Container 通过访问 `dist/routes.json` 获取路由文件。当然你可以使用自己的CDN服务器来存放资源，并且可以根据需求定制自己的测试环境和线上环境。\n\n## ChangeLog\n\n- v0.2.0\n  1. rexxarFetch 对于 iOS WKWebView 亦将 POST 转化成 GET 来处理，需要配合 [rexxar-ios v0.3.0](https://github.com/douban/rexxar-ios#changelog) 及以上使用\n  2. 新增 widgetMessenger, assemblePayload, callbackListener, dispatch\n  3. 废弃 getRexxarWidget\n\n## Contributing\n\n### develop process\n\n1. develop on your branch\n2. run build via eslint\n3. test in example\n4. commit and pr\n\n### release process\n\n1. check build\n2. dump version to new one in package.json\n3. pr and merge into master\n4. add tag and write changelog\n5. npm publish\n\n## License\n\nRexxar is released under the MIT license. See LICENSE for details.\n","readmeFilename":"README.md"}