@viewfly/platform-browser 0.0.1-alpha.10 → 0.0.1-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -1
- package/bundles/fork.d.ts +1 -1
- package/bundles/index.esm.js +2 -4
- package/bundles/index.js +2 -4
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,4 +1,57 @@
|
|
|
1
1
|
Viewfly
|
|
2
2
|
================================
|
|
3
3
|
|
|
4
|
-
Viewfly
|
|
4
|
+
Viewfly 是一个简单、数据驱动的前端视图库。此包为内核运行在浏览器上的支持层。
|
|
5
|
+
|
|
6
|
+
## 安装
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
npm install @viewfly/platform-browser
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## API
|
|
13
|
+
|
|
14
|
+
### createApp()
|
|
15
|
+
|
|
16
|
+
createApp 用于创建一个独立的应用。
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
import { createApp } from '@viewfly/platform-browser'
|
|
20
|
+
|
|
21
|
+
function App() {
|
|
22
|
+
return () => {
|
|
23
|
+
return <div>App!</div>
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const app = createApp(document.getElementById('app'), <App/>)
|
|
28
|
+
|
|
29
|
+
// 销毁 app 实例
|
|
30
|
+
app.destroy()
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### fork()
|
|
34
|
+
|
|
35
|
+
可以在任意组件内创建一个子应用,并可以继承当前组件的上下文(特指当前组件的依赖注入树),常用于创建一个弹窗或对话框。
|
|
36
|
+
|
|
37
|
+
```jsx
|
|
38
|
+
function App() {
|
|
39
|
+
function Modal() {
|
|
40
|
+
return () => {
|
|
41
|
+
return <div>modal</div>
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// 创建子应用
|
|
45
|
+
const childApp = fork(<Modal/>)
|
|
46
|
+
// 启动子应用
|
|
47
|
+
childApp.mount(document.getElementById('modal'))
|
|
48
|
+
// 销毁子应用
|
|
49
|
+
childApp.destroy()
|
|
50
|
+
|
|
51
|
+
return () => {
|
|
52
|
+
return <div>App!</div>
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
完整文档请参考官方网站:[viewfly.org](https://viewfly.org)
|
package/bundles/fork.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { RootNode, Viewfly } from '@viewfly/core';
|
|
2
|
-
export declare function fork(
|
|
2
|
+
export declare function fork(root: RootNode): Viewfly;
|
package/bundles/index.esm.js
CHANGED
|
@@ -244,7 +244,6 @@ DomRenderer = __decorate([
|
|
|
244
244
|
function createApp(host, root, autoUpdate = true) {
|
|
245
245
|
host.innerHTML = '';
|
|
246
246
|
const app = new Viewfly({
|
|
247
|
-
host,
|
|
248
247
|
root,
|
|
249
248
|
autoUpdate,
|
|
250
249
|
providers: [
|
|
@@ -254,12 +253,12 @@ function createApp(host, root, autoUpdate = true) {
|
|
|
254
253
|
}
|
|
255
254
|
]
|
|
256
255
|
});
|
|
257
|
-
app.
|
|
256
|
+
app.mount(host);
|
|
258
257
|
return app;
|
|
259
258
|
}
|
|
260
259
|
|
|
261
260
|
const forkErrorFn = makeError('fork');
|
|
262
|
-
function fork(
|
|
261
|
+
function fork(root) {
|
|
263
262
|
let parentComponent;
|
|
264
263
|
try {
|
|
265
264
|
parentComponent = provide([]);
|
|
@@ -268,7 +267,6 @@ function fork(host, root) {
|
|
|
268
267
|
throw forkErrorFn('The fork function can only be called synchronously within a component.');
|
|
269
268
|
}
|
|
270
269
|
const app = new Viewfly({
|
|
271
|
-
host,
|
|
272
270
|
root,
|
|
273
271
|
context: parentComponent,
|
|
274
272
|
providers: [
|
package/bundles/index.js
CHANGED
|
@@ -246,7 +246,6 @@ exports.DomRenderer = __decorate([
|
|
|
246
246
|
function createApp(host, root, autoUpdate = true) {
|
|
247
247
|
host.innerHTML = '';
|
|
248
248
|
const app = new core.Viewfly({
|
|
249
|
-
host,
|
|
250
249
|
root,
|
|
251
250
|
autoUpdate,
|
|
252
251
|
providers: [
|
|
@@ -256,12 +255,12 @@ function createApp(host, root, autoUpdate = true) {
|
|
|
256
255
|
}
|
|
257
256
|
]
|
|
258
257
|
});
|
|
259
|
-
app.
|
|
258
|
+
app.mount(host);
|
|
260
259
|
return app;
|
|
261
260
|
}
|
|
262
261
|
|
|
263
262
|
const forkErrorFn = core.makeError('fork');
|
|
264
|
-
function fork(
|
|
263
|
+
function fork(root) {
|
|
265
264
|
let parentComponent;
|
|
266
265
|
try {
|
|
267
266
|
parentComponent = core.provide([]);
|
|
@@ -270,7 +269,6 @@ function fork(host, root) {
|
|
|
270
269
|
throw forkErrorFn('The fork function can only be called synchronously within a component.');
|
|
271
270
|
}
|
|
272
271
|
const app = new core.Viewfly({
|
|
273
|
-
host,
|
|
274
272
|
root,
|
|
275
273
|
context: parentComponent,
|
|
276
274
|
providers: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viewfly/platform-browser",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.12",
|
|
4
4
|
"description": "Viewfly is a simple and easy-to-use JavaScript framework with an intuitive development experience.",
|
|
5
5
|
"main": "./bundles/index.js",
|
|
6
6
|
"module": "./bundles/index.esm.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"keywords": [],
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@tanbo/di": "^1.1.4",
|
|
19
|
-
"@viewfly/core": "^0.0.1-alpha.
|
|
19
|
+
"@viewfly/core": "^0.0.1-alpha.12",
|
|
20
20
|
"reflect-metadata": "^0.1.13"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"bugs": {
|
|
38
38
|
"url": "https://github.com/viewfly/viewfly.git/issues"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "e5fdc69779bbfd6a1128b98a30d8732dbda7fcd3"
|
|
41
41
|
}
|