@viewfly/core 0.0.17 → 0.0.19

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.
@@ -2,15 +2,18 @@ import { RootComponent } from '../model/_api';
2
2
  import { NativeNode, NativeRenderer } from './injection-tokens';
3
3
  export declare abstract class RootComponentRef {
4
4
  abstract component: RootComponent;
5
+ }
6
+ export declare abstract class HostRef {
5
7
  abstract host: NativeNode;
6
8
  }
7
9
  export declare class Renderer {
8
10
  private nativeRenderer;
9
11
  private rootComponentRef;
12
+ private hostRef;
10
13
  private componentAtomCaches;
11
- constructor(nativeRenderer: NativeRenderer, rootComponentRef: RootComponentRef);
14
+ private isInit;
15
+ constructor(nativeRenderer: NativeRenderer, rootComponentRef: RootComponentRef, hostRef: HostRef);
12
16
  render(): void;
13
- refresh(): void;
14
17
  private reconcile;
15
18
  private getPrevSibling;
16
19
  private reconcileElement;
@@ -1,5 +1,5 @@
1
1
  import 'reflect-metadata';
2
- import { ReflectiveInjector, normalizeProvider, NullInjector, Injectable } from '@tanbo/di';
2
+ import { ReflectiveInjector, Injector, normalizeProvider, InjectFlags, Injectable, NullInjector } from '@tanbo/di';
3
3
  export * from '@tanbo/di';
4
4
  import { Subject, Subscription, microTask } from '@tanbo/stream';
5
5
 
@@ -152,7 +152,10 @@ class Component extends ReflectiveInjector {
152
152
  return this._changed;
153
153
  }
154
154
  constructor(context, type, props, key) {
155
- super(context, []);
155
+ super(context, [{
156
+ provide: Injector,
157
+ useFactory: () => this
158
+ }]);
156
159
  this.type = type;
157
160
  this.props = props;
158
161
  this.key = key;
@@ -171,11 +174,11 @@ class Component extends ReflectiveInjector {
171
174
  is(target) {
172
175
  return target.$$typeOf === this.$$typeOf;
173
176
  }
174
- addProvide(providers) {
177
+ provide(providers) {
175
178
  providers = Array.isArray(providers) ? providers : [providers];
176
179
  this.normalizedProviders.unshift(...providers.map(i => normalizeProvider(i)));
177
180
  }
178
- init() {
181
+ setup() {
179
182
  const self = this;
180
183
  const props = new Proxy(this.props, {
181
184
  get(_, key) {
@@ -603,7 +606,7 @@ function useEffect(deps, effect) {
603
606
  */
604
607
  function provide(provider) {
605
608
  const component = getSetupContext();
606
- component.addProvide(provider);
609
+ component.provide(provider);
607
610
  return component;
608
611
  }
609
612
  /**
@@ -611,7 +614,7 @@ function provide(provider) {
611
614
  */
612
615
  function inject(token, notFoundValue, flags) {
613
616
  const component = getSetupContext();
614
- return component.parentInjector.get(token, notFoundValue, flags);
617
+ return component.get(token, notFoundValue, flags || InjectFlags.SkipSelf);
615
618
  }
616
619
 
617
620
  function Fragment(props) {
@@ -660,7 +663,7 @@ function withMemo(shouldUpdate, render) {
660
663
  * Viewfly 根组件,用于实现组件状态更新事件通知
661
664
  */
662
665
  class RootComponent extends Component {
663
- constructor(factory, parentInjector = new NullInjector()) {
666
+ constructor(factory, parentInjector) {
664
667
  super(parentInjector, factory, {});
665
668
  this.changeEmitter = new Subject();
666
669
  }
@@ -672,6 +675,8 @@ class RootComponent extends Component {
672
675
 
673
676
  class RootComponentRef {
674
677
  }
678
+ class HostRef {
679
+ }
675
680
  class Atom {
676
681
  constructor(jsxNode, parent) {
677
682
  this.jsxNode = jsxNode;
@@ -682,25 +687,30 @@ class Atom {
682
687
  }
683
688
  }
684
689
  let Renderer = class Renderer {
685
- constructor(nativeRenderer, rootComponentRef) {
690
+ constructor(nativeRenderer, rootComponentRef, hostRef) {
686
691
  this.nativeRenderer = nativeRenderer;
687
692
  this.rootComponentRef = rootComponentRef;
693
+ this.hostRef = hostRef;
688
694
  this.componentAtomCaches = new WeakMap();
695
+ this.isInit = true;
689
696
  }
690
697
  render() {
691
- const { component, host } = this.rootComponentRef;
692
- const atom = new Atom(component, null);
693
- this.buildView(atom, {
694
- isParent: true,
695
- host
696
- });
697
- }
698
- refresh() {
699
- const { component, host } = this.rootComponentRef;
700
- this.reconcile(component, {
701
- host,
702
- isParent: true
703
- });
698
+ const component = this.rootComponentRef.component;
699
+ const host = this.hostRef.host;
700
+ if (this.isInit) {
701
+ const atom = new Atom(component, null);
702
+ this.buildView(atom, {
703
+ isParent: true,
704
+ host
705
+ });
706
+ }
707
+ else {
708
+ this.reconcile(component, {
709
+ host,
710
+ isParent: true
711
+ });
712
+ }
713
+ this.isInit = false;
704
714
  }
705
715
  reconcile(component, context) {
706
716
  if (component.dirty) {
@@ -788,19 +798,18 @@ let Renderer = class Renderer {
788
798
  const changeCommits = {
789
799
  updateComponent: (newAtom, reusedAtom, expectIndex, diffIndex) => {
790
800
  commits.push((offset) => {
801
+ const { render, template } = this.componentAtomCaches.get(reusedAtom.jsxNode);
791
802
  const newProps = newAtom.jsxNode.props;
792
803
  const oldProps = reusedAtom.jsxNode.props;
793
804
  newAtom.jsxNode = reusedAtom.jsxNode;
794
- const { render, template } = this.componentAtomCaches.get(newAtom.jsxNode);
795
805
  const newTemplate = render(newProps, oldProps);
796
806
  this.componentAtomCaches.set(newAtom.jsxNode, {
797
807
  render,
798
- template,
808
+ template: newTemplate,
799
809
  atom: newAtom
800
810
  });
801
811
  if (newTemplate === template) {
802
812
  this.reuseComponentView(newAtom, reusedAtom, context, expectIndex !== diffIndex - offset);
803
- // (newAtom.jsxNode as Component).rendered()
804
813
  return;
805
814
  }
806
815
  if (newTemplate) {
@@ -1019,7 +1028,7 @@ let Renderer = class Renderer {
1019
1028
  }
1020
1029
  }
1021
1030
  componentRender(component, from) {
1022
- const { template, render } = component.init();
1031
+ const { template, render } = component.setup();
1023
1032
  if (template) {
1024
1033
  this.linkTemplate(template, component, from);
1025
1034
  }
@@ -1256,7 +1265,8 @@ let Renderer = class Renderer {
1256
1265
  Renderer = __decorate([
1257
1266
  Injectable(),
1258
1267
  __metadata("design:paramtypes", [NativeRenderer,
1259
- RootComponentRef])
1268
+ RootComponentRef,
1269
+ HostRef])
1260
1270
  ], Renderer);
1261
1271
 
1262
1272
  const viewflyErrorFn = makeError('Viewfly');
@@ -1265,8 +1275,7 @@ const viewflyErrorFn = makeError('Viewfly');
1265
1275
  */
1266
1276
  class Viewfly extends ReflectiveInjector {
1267
1277
  constructor(config) {
1268
- super(new NullInjector(), [
1269
- ...(config.providers || []),
1278
+ super(config.context || new NullInjector(), [
1270
1279
  Renderer,
1271
1280
  {
1272
1281
  provide: RootComponentRef,
@@ -1281,6 +1290,12 @@ class Viewfly extends ReflectiveInjector {
1281
1290
  useFactory() {
1282
1291
  throw viewflyErrorFn('You must implement the `NativeRenderer` interface to start Viewfly!');
1283
1292
  }
1293
+ },
1294
+ {
1295
+ provide: HostRef,
1296
+ useFactory() {
1297
+ throw viewflyErrorFn('Viewfly has not mounted!');
1298
+ }
1284
1299
  }
1285
1300
  ]);
1286
1301
  this.config = config;
@@ -1288,39 +1303,52 @@ class Viewfly extends ReflectiveInjector {
1288
1303
  this.subscription = new Subscription();
1289
1304
  this.rootComponent = this.createRootComponent(config.root);
1290
1305
  }
1306
+ provide(providers) {
1307
+ providers = Array.isArray(providers) ? providers : [providers];
1308
+ this.normalizedProviders.unshift(...providers.map(i => normalizeProvider(i)));
1309
+ return this;
1310
+ }
1291
1311
  /**
1292
1312
  * 启动 Viewfly
1293
1313
  * @param host 应用根节点
1294
1314
  */
1295
1315
  mount(host) {
1296
- const rootComponentRef = this.get(RootComponentRef);
1297
- rootComponentRef.host = host;
1316
+ this.provide({
1317
+ provide: HostRef,
1318
+ useValue: {
1319
+ host
1320
+ }
1321
+ });
1298
1322
  const renderer = this.get(Renderer);
1299
1323
  renderer.render();
1300
1324
  if (this.config.autoUpdate === false) {
1301
- return;
1325
+ return this;
1302
1326
  }
1303
1327
  this.subscription.add(this.rootComponent.changeEmitter.pipe(microTask()).subscribe(() => {
1304
- renderer.refresh();
1328
+ renderer.render();
1305
1329
  }));
1330
+ return this;
1331
+ }
1332
+ render() {
1333
+ const renderer = this.get(Renderer);
1334
+ renderer.render();
1306
1335
  }
1307
1336
  /**
1308
1337
  * 销毁 Viewfly 实例
1309
1338
  */
1310
1339
  destroy() {
1311
- const renderer = this.get(Renderer);
1312
1340
  this.destroyed = true;
1313
1341
  this.rootComponent.markAsDirtied();
1314
1342
  this.subscription.unsubscribe();
1315
- renderer.refresh();
1343
+ this.render();
1316
1344
  }
1317
1345
  createRootComponent(rootNode) {
1318
1346
  return new RootComponent(() => {
1319
1347
  return () => {
1320
1348
  return this.destroyed ? null : rootNode;
1321
1349
  };
1322
- }, this.config.context);
1350
+ }, this);
1323
1351
  }
1324
1352
  }
1325
1353
 
1326
- export { Component, Fragment, JSXComponent, JSXElement, JSXText, NativeRenderer, Ref, Renderer, RootComponent, RootComponentRef, Viewfly, inject, jsx, jsxs, makeError, onDestroy, onMounted, onPropsChanged, onUpdated, provide, useDerived, useEffect, useRef, useSignal, withMemo };
1354
+ export { Component, Fragment, HostRef, JSXComponent, JSXElement, JSXText, NativeRenderer, Ref, Renderer, RootComponent, RootComponentRef, Viewfly, inject, jsx, jsxs, makeError, onDestroy, onMounted, onPropsChanged, onUpdated, provide, useDerived, useEffect, useRef, useSignal, withMemo };
package/bundles/index.js CHANGED
@@ -153,7 +153,10 @@ class Component extends di.ReflectiveInjector {
153
153
  return this._changed;
154
154
  }
155
155
  constructor(context, type, props, key) {
156
- super(context, []);
156
+ super(context, [{
157
+ provide: di.Injector,
158
+ useFactory: () => this
159
+ }]);
157
160
  this.type = type;
158
161
  this.props = props;
159
162
  this.key = key;
@@ -172,11 +175,11 @@ class Component extends di.ReflectiveInjector {
172
175
  is(target) {
173
176
  return target.$$typeOf === this.$$typeOf;
174
177
  }
175
- addProvide(providers) {
178
+ provide(providers) {
176
179
  providers = Array.isArray(providers) ? providers : [providers];
177
180
  this.normalizedProviders.unshift(...providers.map(i => di.normalizeProvider(i)));
178
181
  }
179
- init() {
182
+ setup() {
180
183
  const self = this;
181
184
  const props = new Proxy(this.props, {
182
185
  get(_, key) {
@@ -604,7 +607,7 @@ function useEffect(deps, effect) {
604
607
  */
605
608
  function provide(provider) {
606
609
  const component = getSetupContext();
607
- component.addProvide(provider);
610
+ component.provide(provider);
608
611
  return component;
609
612
  }
610
613
  /**
@@ -612,7 +615,7 @@ function provide(provider) {
612
615
  */
613
616
  function inject(token, notFoundValue, flags) {
614
617
  const component = getSetupContext();
615
- return component.parentInjector.get(token, notFoundValue, flags);
618
+ return component.get(token, notFoundValue, flags || di.InjectFlags.SkipSelf);
616
619
  }
617
620
 
618
621
  function Fragment(props) {
@@ -661,7 +664,7 @@ function withMemo(shouldUpdate, render) {
661
664
  * Viewfly 根组件,用于实现组件状态更新事件通知
662
665
  */
663
666
  class RootComponent extends Component {
664
- constructor(factory, parentInjector = new di.NullInjector()) {
667
+ constructor(factory, parentInjector) {
665
668
  super(parentInjector, factory, {});
666
669
  this.changeEmitter = new stream.Subject();
667
670
  }
@@ -673,6 +676,8 @@ class RootComponent extends Component {
673
676
 
674
677
  class RootComponentRef {
675
678
  }
679
+ class HostRef {
680
+ }
676
681
  class Atom {
677
682
  constructor(jsxNode, parent) {
678
683
  this.jsxNode = jsxNode;
@@ -683,25 +688,30 @@ class Atom {
683
688
  }
684
689
  }
685
690
  exports.Renderer = class Renderer {
686
- constructor(nativeRenderer, rootComponentRef) {
691
+ constructor(nativeRenderer, rootComponentRef, hostRef) {
687
692
  this.nativeRenderer = nativeRenderer;
688
693
  this.rootComponentRef = rootComponentRef;
694
+ this.hostRef = hostRef;
689
695
  this.componentAtomCaches = new WeakMap();
696
+ this.isInit = true;
690
697
  }
691
698
  render() {
692
- const { component, host } = this.rootComponentRef;
693
- const atom = new Atom(component, null);
694
- this.buildView(atom, {
695
- isParent: true,
696
- host
697
- });
698
- }
699
- refresh() {
700
- const { component, host } = this.rootComponentRef;
701
- this.reconcile(component, {
702
- host,
703
- isParent: true
704
- });
699
+ const component = this.rootComponentRef.component;
700
+ const host = this.hostRef.host;
701
+ if (this.isInit) {
702
+ const atom = new Atom(component, null);
703
+ this.buildView(atom, {
704
+ isParent: true,
705
+ host
706
+ });
707
+ }
708
+ else {
709
+ this.reconcile(component, {
710
+ host,
711
+ isParent: true
712
+ });
713
+ }
714
+ this.isInit = false;
705
715
  }
706
716
  reconcile(component, context) {
707
717
  if (component.dirty) {
@@ -789,19 +799,18 @@ exports.Renderer = class Renderer {
789
799
  const changeCommits = {
790
800
  updateComponent: (newAtom, reusedAtom, expectIndex, diffIndex) => {
791
801
  commits.push((offset) => {
802
+ const { render, template } = this.componentAtomCaches.get(reusedAtom.jsxNode);
792
803
  const newProps = newAtom.jsxNode.props;
793
804
  const oldProps = reusedAtom.jsxNode.props;
794
805
  newAtom.jsxNode = reusedAtom.jsxNode;
795
- const { render, template } = this.componentAtomCaches.get(newAtom.jsxNode);
796
806
  const newTemplate = render(newProps, oldProps);
797
807
  this.componentAtomCaches.set(newAtom.jsxNode, {
798
808
  render,
799
- template,
809
+ template: newTemplate,
800
810
  atom: newAtom
801
811
  });
802
812
  if (newTemplate === template) {
803
813
  this.reuseComponentView(newAtom, reusedAtom, context, expectIndex !== diffIndex - offset);
804
- // (newAtom.jsxNode as Component).rendered()
805
814
  return;
806
815
  }
807
816
  if (newTemplate) {
@@ -1020,7 +1029,7 @@ exports.Renderer = class Renderer {
1020
1029
  }
1021
1030
  }
1022
1031
  componentRender(component, from) {
1023
- const { template, render } = component.init();
1032
+ const { template, render } = component.setup();
1024
1033
  if (template) {
1025
1034
  this.linkTemplate(template, component, from);
1026
1035
  }
@@ -1257,7 +1266,8 @@ exports.Renderer = class Renderer {
1257
1266
  exports.Renderer = __decorate([
1258
1267
  di.Injectable(),
1259
1268
  __metadata("design:paramtypes", [NativeRenderer,
1260
- RootComponentRef])
1269
+ RootComponentRef,
1270
+ HostRef])
1261
1271
  ], exports.Renderer);
1262
1272
 
1263
1273
  const viewflyErrorFn = makeError('Viewfly');
@@ -1266,8 +1276,7 @@ const viewflyErrorFn = makeError('Viewfly');
1266
1276
  */
1267
1277
  class Viewfly extends di.ReflectiveInjector {
1268
1278
  constructor(config) {
1269
- super(new di.NullInjector(), [
1270
- ...(config.providers || []),
1279
+ super(config.context || new di.NullInjector(), [
1271
1280
  exports.Renderer,
1272
1281
  {
1273
1282
  provide: RootComponentRef,
@@ -1282,6 +1291,12 @@ class Viewfly extends di.ReflectiveInjector {
1282
1291
  useFactory() {
1283
1292
  throw viewflyErrorFn('You must implement the `NativeRenderer` interface to start Viewfly!');
1284
1293
  }
1294
+ },
1295
+ {
1296
+ provide: HostRef,
1297
+ useFactory() {
1298
+ throw viewflyErrorFn('Viewfly has not mounted!');
1299
+ }
1285
1300
  }
1286
1301
  ]);
1287
1302
  this.config = config;
@@ -1289,43 +1304,57 @@ class Viewfly extends di.ReflectiveInjector {
1289
1304
  this.subscription = new stream.Subscription();
1290
1305
  this.rootComponent = this.createRootComponent(config.root);
1291
1306
  }
1307
+ provide(providers) {
1308
+ providers = Array.isArray(providers) ? providers : [providers];
1309
+ this.normalizedProviders.unshift(...providers.map(i => di.normalizeProvider(i)));
1310
+ return this;
1311
+ }
1292
1312
  /**
1293
1313
  * 启动 Viewfly
1294
1314
  * @param host 应用根节点
1295
1315
  */
1296
1316
  mount(host) {
1297
- const rootComponentRef = this.get(RootComponentRef);
1298
- rootComponentRef.host = host;
1317
+ this.provide({
1318
+ provide: HostRef,
1319
+ useValue: {
1320
+ host
1321
+ }
1322
+ });
1299
1323
  const renderer = this.get(exports.Renderer);
1300
1324
  renderer.render();
1301
1325
  if (this.config.autoUpdate === false) {
1302
- return;
1326
+ return this;
1303
1327
  }
1304
1328
  this.subscription.add(this.rootComponent.changeEmitter.pipe(stream.microTask()).subscribe(() => {
1305
- renderer.refresh();
1329
+ renderer.render();
1306
1330
  }));
1331
+ return this;
1332
+ }
1333
+ render() {
1334
+ const renderer = this.get(exports.Renderer);
1335
+ renderer.render();
1307
1336
  }
1308
1337
  /**
1309
1338
  * 销毁 Viewfly 实例
1310
1339
  */
1311
1340
  destroy() {
1312
- const renderer = this.get(exports.Renderer);
1313
1341
  this.destroyed = true;
1314
1342
  this.rootComponent.markAsDirtied();
1315
1343
  this.subscription.unsubscribe();
1316
- renderer.refresh();
1344
+ this.render();
1317
1345
  }
1318
1346
  createRootComponent(rootNode) {
1319
1347
  return new RootComponent(() => {
1320
1348
  return () => {
1321
1349
  return this.destroyed ? null : rootNode;
1322
1350
  };
1323
- }, this.config.context);
1351
+ }, this);
1324
1352
  }
1325
1353
  }
1326
1354
 
1327
1355
  exports.Component = Component;
1328
1356
  exports.Fragment = Fragment;
1357
+ exports.HostRef = HostRef;
1329
1358
  exports.JSXComponent = JSXComponent;
1330
1359
  exports.JSXElement = JSXElement;
1331
1360
  exports.JSXText = JSXText;
@@ -1,5 +1,5 @@
1
- import { Provider, ReflectiveInjector, AbstractType, Type, InjectionToken, InjectFlags, Injector } from '@tanbo/di';
2
- import { Props, Key, JSXTypeof } from './jsx-element';
1
+ import { AbstractType, InjectFlags, InjectionToken, Injector, Provider, ReflectiveInjector, Type } from '@tanbo/di';
2
+ import { JSXTypeof, Key, Props } from './jsx-element';
3
3
  import { JSXInternal } from './types';
4
4
  export declare class JSXComponent {
5
5
  props: Props;
@@ -30,10 +30,10 @@ export declare class Component extends ReflectiveInjector implements JSXTypeof {
30
30
  private isFirstRending;
31
31
  constructor(context: Injector, type: JSXInternal.ElementClass, props: Props, key?: Key | undefined);
32
32
  is(target: JSXTypeof): boolean;
33
- addProvide<T>(providers: Provider<T> | Provider<T>[]): void;
34
- init(): {
35
- template: JSXInternal.JSXChildNode;
36
- render: (newProps: Props, oldProps: Props) => JSXInternal.JSXChildNode;
33
+ provide<T>(providers: Provider<T> | Provider<T>[]): void;
34
+ setup(): {
35
+ template: JSXInternal.JSXNode;
36
+ render: (newProps: Props, oldProps: Props) => JSXInternal.JSXNode;
37
37
  };
38
38
  markAsDirtied(): void;
39
39
  markAsChanged(): void;
@@ -1,11 +1,11 @@
1
1
  import { JSXComponent } from './component';
2
2
  import { JSXInternal } from './types';
3
3
  export interface Props {
4
- children?: JSXInternal.JSXChildNode | JSXInternal.JSXChildNode[];
4
+ children?: JSXInternal.JSXNode | JSXInternal.JSXNode[];
5
5
  [key: string]: any;
6
6
  [key: symbol]: any;
7
7
  }
8
- export declare function Fragment(props: Props): () => JSXInternal.JSXChildNode | JSXInternal.JSXChildNode[];
8
+ export declare function Fragment(props: Props): () => JSXInternal.JSXNode | JSXInternal.JSXNode[];
9
9
  export type Key = number | string;
10
10
  export declare function jsx(name: string, props: Props, key?: Key): JSXElement;
11
11
  export declare function jsx(setup: JSXInternal.ElementClass, props: Props, key?: Key): JSXComponent;
@@ -1,5 +1,4 @@
1
1
  import { Subject } from '@tanbo/stream';
2
- import { NullInjector } from '@tanbo/di';
3
2
  import { Component } from './component';
4
3
  import { JSXInternal } from './types';
5
4
  /**
@@ -7,6 +6,6 @@ import { JSXInternal } from './types';
7
6
  */
8
7
  export declare class RootComponent extends Component {
9
8
  changeEmitter: Subject<void>;
10
- constructor(factory: JSXInternal.ElementClass, parentInjector?: NullInjector);
9
+ constructor(factory: JSXInternal.ElementClass, parentInjector: any);
11
10
  markAsChanged(): void;
12
11
  }
@@ -1,11 +1,12 @@
1
1
  import { Key, ExtractInstanceType, Ref } from './_api';
2
+ export type JSXNode = JSXInternal.JSXNode;
2
3
  export declare namespace JSXInternal {
3
4
  type ClassNames = string | Record<string, unknown> | ClassNames[];
4
5
  interface ComponentInstance<P> {
5
- $render(): JSXChildNode;
6
+ $render(): JSXNode;
6
7
  $shouldUpdate?(currentProps: P, prevProps: P): boolean;
7
8
  }
8
- type JSXChildNode = Element | ElementClass | string | number | boolean | null | undefined | JSXChildNode[];
9
+ type JSXNode = Element | JSXInternal.ElementClass | string | number | boolean | null | undefined | JSXNode[];
9
10
  interface Element<P = any, C extends string | ElementClass<P> = string | ElementClass<P>> {
10
11
  }
11
12
  interface IntrinsicAttributes {
@@ -16,7 +17,7 @@ export declare namespace JSXInternal {
16
17
  ref?: Ref<T, ExtractInstanceType<T>> | Ref<T, ExtractInstanceType<T>>[];
17
18
  }
18
19
  interface ElementClass<P = any> {
19
- (props?: P): () => (JSXChildNode | ComponentInstance<P>);
20
+ (props?: P): () => (JSXNode | ComponentInstance<P>);
20
21
  }
21
22
  interface ElementChildrenAttribute {
22
23
  }
@@ -5,29 +5,29 @@ import { JSXInternal } from './model/_api';
5
5
  * Viewfly 配置项
6
6
  */
7
7
  export interface Config {
8
- /** Viewfly IoC 容器中提供者集合 */
9
- providers?: Provider[];
10
8
  /** 是否自动更新视图 */
11
9
  autoUpdate?: boolean;
12
10
  /** 根节点 */
13
- root: JSXInternal.JSXChildNode;
14
- /** 根组件的上下文 */
11
+ root: JSXInternal.JSXNode;
12
+ /** 应用的上下文 */
15
13
  context?: Injector;
16
14
  }
17
15
  /**
18
16
  * Viewfly 核心类,用于启动一个 Viewfly 应用
19
17
  */
20
- export declare class Viewfly extends ReflectiveInjector {
18
+ export declare class Viewfly<T extends NativeNode = NativeNode> extends ReflectiveInjector {
21
19
  private config;
22
20
  private destroyed;
23
21
  private rootComponent;
24
22
  private subscription;
25
23
  constructor(config: Config);
24
+ provide(providers: Provider | Provider[]): this;
26
25
  /**
27
26
  * 启动 Viewfly
28
27
  * @param host 应用根节点
29
28
  */
30
- mount(host: NativeNode): void;
29
+ mount(host: T): this;
30
+ render(): void;
31
31
  /**
32
32
  * 销毁 Viewfly 实例
33
33
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viewfly/core",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
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",
@@ -29,8 +29,8 @@
29
29
  "license": "MIT",
30
30
  "keywords": [],
31
31
  "dependencies": {
32
- "@tanbo/di": "^1.1.5",
33
- "@tanbo/stream": "^1.2.0",
32
+ "@tanbo/di": "^1.1.8",
33
+ "@tanbo/stream": "^1.2.3",
34
34
  "reflect-metadata": "^0.1.13"
35
35
  },
36
36
  "devDependencies": {
@@ -51,5 +51,5 @@
51
51
  "bugs": {
52
52
  "url": "https://github.com/viewfly/viewfly.git/issues"
53
53
  },
54
- "gitHead": "7a61edbca87f411d2ddbb390eb0b2e0416d80551"
54
+ "gitHead": "9276451814bcda728846876797e327d297a31b0e"
55
55
  }