@viewfly/platform-browser 0.0.1-alpha.11 → 0.0.1-alpha.13

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 CHANGED
@@ -1,4 +1,57 @@
1
1
  Viewfly
2
2
  ================================
3
3
 
4
- Viewfly 是一个简单、数据驱动的前端视图库,完整文档请参考官方网站:[viewfly.org](https://viewfly.org)
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(host: HTMLElement, root: RootNode): Viewfly;
2
+ export declare function fork(root: RootNode): Viewfly;
@@ -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.run();
256
+ app.mount(host);
258
257
  return app;
259
258
  }
260
259
 
261
260
  const forkErrorFn = makeError('fork');
262
- function fork(host, root) {
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.run();
258
+ app.mount(host);
260
259
  return app;
261
260
  }
262
261
 
263
262
  const forkErrorFn = core.makeError('fork');
264
- function fork(host, root) {
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,14 +1,11 @@
1
1
  {
2
2
  "name": "@viewfly/platform-browser",
3
- "version": "0.0.1-alpha.11",
4
- "description": "Viewfly is a simple and easy-to-use JavaScript framework with an intuitive development experience.",
3
+ "version": "0.0.1-alpha.13",
4
+ "description": "This project is used to enable the Viewfly framework to run in a browser.",
5
5
  "main": "./bundles/index.js",
6
6
  "module": "./bundles/index.esm.js",
7
7
  "typings": "./bundles/public-api.d.ts",
8
8
  "scripts": {
9
- "start": "webpack-dev-server",
10
- "test": "cross-env env=test jest",
11
- "test-c": "cross-env env=test jest --coverage",
12
9
  "build:lib": "rimraf bundles && rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript",
13
10
  "publish:lib": "npm run build:lib && npm publish --access=public"
14
11
  },
@@ -16,7 +13,7 @@
16
13
  "keywords": [],
17
14
  "dependencies": {
18
15
  "@tanbo/di": "^1.1.4",
19
- "@viewfly/core": "^0.0.1-alpha.11",
16
+ "@viewfly/core": "^0.0.1-alpha.13",
20
17
  "reflect-metadata": "^0.1.13"
21
18
  },
22
19
  "devDependencies": {
@@ -36,6 +33,5 @@
36
33
  },
37
34
  "bugs": {
38
35
  "url": "https://github.com/viewfly/viewfly.git/issues"
39
- },
40
- "gitHead": "38e6182b1ae82b0f9626742507ca7a4583d182f9"
36
+ }
41
37
  }