Currently, in both Vue [1] and Rax [2] there are some code for generating
document object, instance config and function to require native modules etc. I
think they could be included in shared JS runtime code and be executed to
generate a `weex` variable before each creating the instance by a certain JS
Framework.
So I suggest when `global.createInstance` called from native [3], We can
generate a `weex` variable besides detecting the JS framework this instance
uses by default. And it has some properties below:
* `weex.requireModule(name)`: require a native module by name.
* `weex.requireFramework(name)`: create a framework by name when first call,
and return it.
* `weex.config`: which includes `bundleUrl`, `bundleVersion`, `WXEnvironment`
...
* `weex.document`: this `Document` instance.
* `weex.unit`: supported CSS units and values, for example:
`weex.unit.rgba(r,g,b,a)`.
At the same time, we have an `env` object to pass into JS framework for init
this Weex page:
* `info`: kv-pairs from bundle header comment. for example: `{ framework,
version, ... }`.
* `config`: just `weex.config`.
* `callbacks`: CallbackManager instance for this Weex page.
* `created`: the timestamp this Weex page created.
* `variables`: all instance variables and service variables injected from JS
Services
Thanks.
[1]
https://github.com/vuejs/vue/blob/dev/src/platforms/weex/framework.js#L87:L93
[2]
https://github.com/alibaba/rax/blob/master/packages/weex-rax-framework/src/index.js#L159-L337
[3] https://github.com/alibaba/weex/blob/dev/html5/runtime/init.js#L51:L91
Jinjiang