@viewfly/platform-browser 0.0.1-alpha.3 → 0.0.1-alpha.5

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.
@@ -0,0 +1,2 @@
1
+ import { RootNode, Viewfly } from '@viewfly/core';
2
+ export declare function fork(host: HTMLElement, root: RootNode): Viewfly;
@@ -1,4 +1,4 @@
1
- import { NativeRenderer, Viewfly } from '@viewfly/core';
1
+ import { NativeRenderer, Viewfly, makeError, provide, onDestroy } from '@viewfly/core';
2
2
  import { Injectable } from '@tanbo/di';
3
3
 
4
4
  /******************************************************************************
@@ -265,8 +265,34 @@ function createApp(host, root, autoUpdate = true) {
265
265
  }
266
266
  ]
267
267
  });
268
- app.start();
268
+ app.run();
269
269
  return app;
270
270
  }
271
271
 
272
- export { DomRenderer, createApp };
272
+ const forkErrorFn = makeError('fork');
273
+ function fork(host, root) {
274
+ let parentComponent;
275
+ try {
276
+ parentComponent = provide([]);
277
+ }
278
+ catch (_a) {
279
+ throw forkErrorFn('The fork function can only be called synchronously within a component.');
280
+ }
281
+ const app = new Viewfly({
282
+ host,
283
+ root,
284
+ context: parentComponent,
285
+ providers: [
286
+ {
287
+ provide: NativeRenderer,
288
+ useClass: DomRenderer
289
+ }
290
+ ]
291
+ });
292
+ onDestroy(() => {
293
+ app.destroy();
294
+ });
295
+ return app;
296
+ }
297
+
298
+ export { DomRenderer, createApp, fork };
package/bundles/index.js CHANGED
@@ -267,8 +267,35 @@ function createApp(host, root, autoUpdate = true) {
267
267
  }
268
268
  ]
269
269
  });
270
- app.start();
270
+ app.run();
271
+ return app;
272
+ }
273
+
274
+ const forkErrorFn = core.makeError('fork');
275
+ function fork(host, root) {
276
+ let parentComponent;
277
+ try {
278
+ parentComponent = core.provide([]);
279
+ }
280
+ catch (_a) {
281
+ throw forkErrorFn('The fork function can only be called synchronously within a component.');
282
+ }
283
+ const app = new core.Viewfly({
284
+ host,
285
+ root,
286
+ context: parentComponent,
287
+ providers: [
288
+ {
289
+ provide: core.NativeRenderer,
290
+ useClass: exports.DomRenderer
291
+ }
292
+ ]
293
+ });
294
+ core.onDestroy(() => {
295
+ app.destroy();
296
+ });
271
297
  return app;
272
298
  }
273
299
 
274
300
  exports.createApp = createApp;
301
+ exports.fork = fork;
@@ -1,2 +1,3 @@
1
1
  export * from './create-app';
2
+ export * from './fork';
2
3
  export * from './dom-renderer';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viewfly/platform-browser",
3
- "version": "0.0.1-alpha.3",
3
+ "version": "0.0.1-alpha.5",
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.3",
19
+ "@viewfly/core": "^0.0.1-alpha.5",
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": "e0795c315c3b3e1df2e3d2d9f823843b91838ff6"
40
+ "gitHead": "135aeda546b83c7947e888dfe40860858123b6fc"
41
41
  }