@viewfly/core 0.0.28 → 0.0.29

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.
@@ -626,60 +626,30 @@ function getSetupContext(need = true) {
626
626
  function getSignalDepsContext() {
627
627
  return signalDepsStack[signalDepsStack.length - 1];
628
628
  }
629
- class JSXComponent {
630
- constructor(props, factory) {
631
- this.props = props;
632
- this.factory = factory;
633
- }
634
- createInstance(injector) {
635
- return this.factory(injector, this.props);
636
- }
637
- }
638
629
  /**
639
630
  * Viewfly 组件管理类,用于管理组件的生命周期,上下文等
640
631
  */
641
632
  class Component extends ReflectiveInjector {
642
- get dirty() {
643
- return this._dirty;
644
- }
645
- get changed() {
646
- return this._changed;
647
- }
648
- constructor(context, type, props, key) {
633
+ constructor(context, jsxNode, props, key) {
649
634
  super(context, [{
650
635
  provide: Injector,
651
636
  useFactory: () => this
652
637
  }]);
653
- this.type = type;
638
+ this.jsxNode = jsxNode;
654
639
  this.props = props;
655
640
  this.key = key;
656
- this.$$typeOf = this.type;
657
641
  this.destroyCallbacks = [];
658
642
  this.mountCallbacks = [];
659
643
  this.propsChangedCallbacks = [];
660
644
  this.updatedCallbacks = [];
661
- this.changedSubComponents = new Set();
662
- this._dirty = true;
663
- this._changed = true;
664
645
  this.updatedDestroyCallbacks = [];
665
646
  this.propsChangedDestroyCallbacks = [];
666
647
  this.isFirstRending = true;
667
- this.parentComponent = this.parentInjector;
668
- }
669
- is(target) {
670
- return target.$$typeOf === this.$$typeOf;
671
- }
672
- provide(providers) {
673
- providers = Array.isArray(providers) ? providers : [providers];
674
- this.normalizedProviders.unshift(...providers.map(i => normalizeProvider(i)));
675
- }
676
- setup() {
677
648
  const self = this;
678
- const props = new Proxy(this.props, {
649
+ const proxiesProps = new Proxy(props, {
679
650
  get(_, key) {
680
- if (self.props) {
681
- return self.props[key];
682
- }
651
+ // 必须用 self,因为 props 会随着页面更新变更,使用 self 才能更新引用
652
+ return self.props[key];
683
653
  },
684
654
  set() {
685
655
  // 防止因外部捕获异常引引起的缓存未清理的问题
@@ -691,84 +661,72 @@ class Component extends ReflectiveInjector {
691
661
  });
692
662
  componentSetupStack.push(this);
693
663
  let isSetup = true;
694
- const render = this.type(props);
664
+ const render = this.jsxNode.type(proxiesProps);
695
665
  const isRenderFn = typeof render === 'function';
696
- const componentInstance = isRenderFn ? { $render: render } : render;
697
- let refs = toRefs(this.props.ref);
698
- onMounted(() => {
699
- for (const ref of refs) {
700
- ref.bind(componentInstance);
666
+ this.instance = isRenderFn ? { $render: render } : render;
667
+ this.refs = toRefs(props.ref);
668
+ this.mountCallbacks.push(() => {
669
+ for (const ref of this.refs) {
670
+ ref.bind(this.instance);
701
671
  }
702
672
  });
703
- onDestroy(() => {
704
- for (const ref of refs) {
705
- ref.unBind(componentInstance);
673
+ this.destroyCallbacks.push(() => {
674
+ for (const ref of this.refs) {
675
+ ref.unBind(this.instance);
706
676
  }
707
677
  });
708
678
  isSetup = false;
709
679
  componentSetupStack.pop();
680
+ }
681
+ render() {
710
682
  signalDepsStack.push([]);
711
- let template = componentInstance.$render();
683
+ let template = this.instance.$render();
712
684
  const deps = signalDepsStack.pop();
713
685
  this.unWatch = useEffect(deps, () => {
714
- this.markAsDirtied();
686
+ this.jsxNode.markAsDirtied();
715
687
  });
716
- return {
717
- template,
718
- render: (newProps, oldProps) => {
719
- if (newProps !== oldProps) {
720
- const { add, remove, replace } = getObjectChanges(newProps, oldProps);
721
- if (add.length || remove.length || replace.length) {
722
- this.invokePropsChangedHooks(newProps);
723
- }
724
- const newRefs = toRefs(newProps.ref);
725
- for (const oldRef of refs) {
726
- if (!newRefs.includes(oldRef)) {
727
- oldRef.unBind(componentInstance);
728
- }
729
- }
730
- for (const newRef of newRefs) {
731
- if (!refs.includes(newRef)) {
732
- newRef.bind(componentInstance);
733
- }
734
- }
735
- refs = newRefs;
736
- }
737
- if (typeof componentInstance.$shouldUpdate === 'function') {
738
- if (!componentInstance.$shouldUpdate(newProps, oldProps)) {
739
- return template;
740
- }
741
- }
742
- this.unWatch();
743
- signalDepsStack.push([]);
744
- template = componentInstance.$render();
745
- const deps = signalDepsStack.pop();
746
- this.unWatch = useEffect(deps, () => {
747
- this.markAsDirtied();
748
- });
749
- return template;
750
- }
751
- };
688
+ this.template = template;
689
+ return template;
752
690
  }
753
- markAsDirtied() {
754
- this._dirty = true;
755
- this.markAsChanged();
756
- }
757
- markAsChanged(changedComponent) {
758
- if (changedComponent) {
759
- this.changedSubComponents.add(changedComponent);
691
+ update(newProps, forceUpdate = false) {
692
+ const oldProps = this.props;
693
+ const { add, remove, replace } = getObjectChanges(newProps, this.props);
694
+ if (add.length || remove.length || replace.length) {
695
+ this.invokePropsChangedHooks(newProps);
696
+ }
697
+ const newRefs = toRefs(newProps.ref);
698
+ for (const oldRef of this.refs) {
699
+ if (!newRefs.includes(oldRef)) {
700
+ oldRef.unBind(this.instance);
701
+ }
760
702
  }
761
- if (this._changed) {
762
- return;
703
+ for (const newRef of newRefs) {
704
+ if (!this.refs.includes(newRef)) {
705
+ newRef.bind(this.instance);
706
+ }
763
707
  }
764
- this._changed = true;
765
- this.parentComponent.markAsChanged(this);
708
+ this.refs = newRefs;
709
+ if (!forceUpdate && typeof this.instance.$useMemo === 'function') {
710
+ if (this.instance.$useMemo(newProps, oldProps)) {
711
+ return this.template;
712
+ }
713
+ }
714
+ this.unWatch();
715
+ signalDepsStack.push([]);
716
+ this.template = this.instance.$render();
717
+ const deps = signalDepsStack.pop();
718
+ this.unWatch = useEffect(deps, () => {
719
+ this.jsxNode.markAsDirtied();
720
+ });
721
+ return this.template;
722
+ }
723
+ provide(providers) {
724
+ providers = Array.isArray(providers) ? providers : [providers];
725
+ this.normalizedProviders.unshift(...providers.map(i => normalizeProvider(i)));
766
726
  }
767
727
  rendered() {
768
- this.changedSubComponents.clear();
769
728
  const is = this.isFirstRending;
770
729
  this.isFirstRending = false;
771
- this._dirty = this._changed = false;
772
730
  if (is) {
773
731
  this.invokeUpdatedHooks();
774
732
  this.invokeMountHooks();
@@ -1116,6 +1074,9 @@ function inject(token, notFoundValue = THROW_IF_NOT_FOUND, flags = InjectFlags.S
1116
1074
  return component.get(token, notFoundValue, flags);
1117
1075
  }
1118
1076
 
1077
+ class NativeRenderer {
1078
+ }
1079
+
1119
1080
  function Fragment(props) {
1120
1081
  return () => {
1121
1082
  return props.children;
@@ -1125,9 +1086,9 @@ function jsx(setup, props, key) {
1125
1086
  if (typeof setup === 'string') {
1126
1087
  return JSXElement.create(setup, props, key);
1127
1088
  }
1128
- return new JSXComponent(props, function (context, props) {
1129
- return new Component(context, setup, props, key);
1130
- });
1089
+ return new JSXComponent(setup, props, function (context, jsxNode) {
1090
+ return new Component(context, jsxNode, props, key);
1091
+ }, key);
1131
1092
  }
1132
1093
  const jsxs = jsx;
1133
1094
  class JSXText {
@@ -1153,66 +1114,91 @@ class JSXElement {
1153
1114
  return target.$$typeOf === this.$$typeOf;
1154
1115
  }
1155
1116
  }
1156
-
1157
- function withMemo(shouldUpdate, render) {
1158
- return {
1159
- $shouldUpdate: shouldUpdate,
1160
- $render: render
1161
- };
1162
- }
1163
-
1164
- /**
1165
- * Viewfly 根组件,用于实现组件状态更新事件通知
1166
- */
1167
- class RootComponent extends Component {
1168
- constructor(parentInjector, factory) {
1169
- super(parentInjector, factory, {});
1170
- this.onChange = null;
1117
+ class JSXComponent {
1118
+ get dirty() {
1119
+ return this._dirty;
1171
1120
  }
1172
- markAsChanged(changedComponent) {
1173
- var _a;
1121
+ get changed() {
1122
+ return this._changed;
1123
+ }
1124
+ constructor(type, props, factory, key) {
1125
+ this.type = type;
1126
+ this.props = props;
1127
+ this.factory = factory;
1128
+ this.key = key;
1129
+ this.$$typeOf = this.type;
1130
+ this.parentComponent = null;
1131
+ this.changedSubComponents = new Set();
1132
+ this._dirty = true;
1174
1133
  this._changed = true;
1134
+ }
1135
+ markAsDirtied() {
1136
+ this._dirty = true;
1137
+ this.markAsChanged();
1138
+ }
1139
+ markAsChanged(changedComponent) {
1175
1140
  if (changedComponent) {
1176
1141
  this.changedSubComponents.add(changedComponent);
1177
1142
  }
1178
- (_a = this.onChange) === null || _a === void 0 ? void 0 : _a.call(this);
1143
+ if (this._changed) {
1144
+ return;
1145
+ }
1146
+ this._changed = true;
1147
+ this.parentComponent.markAsChanged(this);
1148
+ }
1149
+ reset() {
1150
+ this.changedSubComponents.clear();
1151
+ this.instance.rendered();
1152
+ this._dirty = this._changed = false;
1153
+ }
1154
+ is(target) {
1155
+ return target.$$typeOf === this.$$typeOf;
1156
+ }
1157
+ createInstance(injector) {
1158
+ this.parentComponent = injector.jsxNode;
1159
+ this.instance = this.factory(injector, this);
1160
+ return this.instance;
1179
1161
  }
1180
1162
  }
1181
1163
 
1182
- class NativeRenderer {
1164
+ function withMemo(canUseMemo, render) {
1165
+ return {
1166
+ $useMemo: canUseMemo,
1167
+ $render: render
1168
+ };
1183
1169
  }
1184
1170
 
1185
- function createRenderer(component, nativeRenderer) {
1171
+ function createRenderer(jsxComponent, nativeRenderer, parentComponent) {
1186
1172
  let isInit = true;
1187
1173
  return function render(host) {
1188
1174
  if (isInit) {
1189
1175
  isInit = false;
1190
1176
  const atom = {
1191
- jsxNode: component,
1177
+ jsxNode: jsxComponent,
1192
1178
  parent: null,
1193
1179
  sibling: null,
1194
1180
  child: null,
1195
1181
  nativeNode: null
1196
1182
  };
1197
- buildView(nativeRenderer, atom, {
1183
+ buildView(nativeRenderer, parentComponent, atom, {
1198
1184
  isParent: true,
1199
1185
  host
1200
1186
  });
1201
1187
  }
1202
1188
  else {
1203
- updateView(nativeRenderer, component);
1189
+ updateView(nativeRenderer, jsxComponent);
1204
1190
  }
1205
1191
  };
1206
1192
  }
1207
- function buildView(nativeRenderer, atom, context) {
1208
- if (atom.jsxNode instanceof Component) {
1209
- componentRender(atom.jsxNode, atom, context);
1193
+ function buildView(nativeRenderer, parentComponent, atom, context) {
1194
+ if (atom.jsxNode instanceof JSXComponent) {
1195
+ const component = componentRender(atom.jsxNode, parentComponent, atom, context);
1210
1196
  let child = atom.child;
1211
1197
  while (child) {
1212
- buildView(nativeRenderer, child, context);
1198
+ buildView(nativeRenderer, component, child, context);
1213
1199
  child = child.sibling;
1214
1200
  }
1215
- atom.jsxNode.rendered();
1201
+ atom.jsxNode.reset();
1216
1202
  }
1217
1203
  else {
1218
1204
  let nativeNode;
@@ -1239,7 +1225,7 @@ function buildView(nativeRenderer, atom, context) {
1239
1225
  };
1240
1226
  let child = atom.child;
1241
1227
  while (child) {
1242
- buildView(nativeRenderer, child, childContext);
1228
+ buildView(nativeRenderer, parentComponent, child, childContext);
1243
1229
  child = child.sibling;
1244
1230
  }
1245
1231
  }
@@ -1250,24 +1236,24 @@ function buildView(nativeRenderer, atom, context) {
1250
1236
  }
1251
1237
  }
1252
1238
  }
1253
- function updateView(nativeRenderer, component) {
1254
- if (component.dirty) {
1255
- applyChanges(nativeRenderer, component);
1256
- component.rendered();
1239
+ function updateView(nativeRenderer, jsxComponent) {
1240
+ if (jsxComponent.dirty) {
1241
+ applyChanges(nativeRenderer, jsxComponent);
1242
+ jsxComponent.reset();
1257
1243
  }
1258
- else if (component.changed) {
1259
- component.changedSubComponents.forEach(child => {
1244
+ else if (jsxComponent.changed) {
1245
+ jsxComponent.changedSubComponents.forEach(child => {
1260
1246
  updateView(nativeRenderer, child);
1261
1247
  });
1262
- component.rendered();
1248
+ jsxComponent.reset();
1263
1249
  }
1264
1250
  }
1265
- function applyChanges(nativeRenderer, component) {
1266
- const { atom, render, host, isParent } = component.$$view;
1251
+ function applyChanges(nativeRenderer, jsxComponent) {
1252
+ const { atom, host, isParent } = jsxComponent.$$view;
1267
1253
  const diffAtom = atom.child;
1268
- const template = render(component.props, component.props);
1254
+ const template = jsxComponent.instance.update(jsxComponent.instance.props, true);
1269
1255
  if (template) {
1270
- linkTemplate(template, component, atom);
1256
+ linkTemplate(template, jsxComponent, atom);
1271
1257
  }
1272
1258
  else {
1273
1259
  atom.child = null;
@@ -1276,14 +1262,14 @@ function applyChanges(nativeRenderer, component) {
1276
1262
  host,
1277
1263
  isParent
1278
1264
  };
1279
- diff(nativeRenderer, atom.child, diffAtom, context, 0, 0);
1265
+ diff(nativeRenderer, jsxComponent.instance, atom.child, diffAtom, context, 0, 0);
1280
1266
  const next = atom.sibling;
1281
- if (next && next.jsxNode instanceof Component) {
1267
+ if (next && next.jsxNode instanceof JSXComponent) {
1282
1268
  next.jsxNode.$$view.host = context.host;
1283
1269
  next.jsxNode.$$view.isParent = context.isParent;
1284
1270
  }
1285
1271
  }
1286
- function diff(nativeRenderer, newAtom, oldAtom, context, expectIndex, index) {
1272
+ function diff(nativeRenderer, parentComponent, newAtom, oldAtom, context, expectIndex, index) {
1287
1273
  const oldChildren = [];
1288
1274
  while (oldAtom) {
1289
1275
  oldChildren.push({
@@ -1297,13 +1283,14 @@ function diff(nativeRenderer, newAtom, oldAtom, context, expectIndex, index) {
1297
1283
  const changeCommits = {
1298
1284
  updateComponent: (newAtom, reusedAtom, expectIndex, diffIndex) => {
1299
1285
  commits.push((offset) => {
1300
- const { render, template } = reusedAtom.jsxNode.$$view;
1286
+ const oldJSXComponent = reusedAtom.jsxNode;
1287
+ const instance = oldJSXComponent.instance;
1301
1288
  const newProps = newAtom.jsxNode.props;
1302
- const oldProps = reusedAtom.jsxNode.props;
1303
- newAtom.jsxNode = reusedAtom.jsxNode;
1304
- const newTemplate = render(newProps, oldProps);
1305
- newAtom.jsxNode.$$view = Object.assign({ render, template: newTemplate, atom: newAtom }, context);
1306
- if (newTemplate === template) {
1289
+ const oldTemplate = instance.template;
1290
+ const newTemplate = instance.update(newProps);
1291
+ oldJSXComponent.$$view = Object.assign({ atom: newAtom }, context);
1292
+ newAtom.jsxNode = oldJSXComponent;
1293
+ if (newTemplate === oldTemplate) {
1307
1294
  reuseComponentView(nativeRenderer, newAtom, reusedAtom, context, expectIndex !== diffIndex - offset);
1308
1295
  return;
1309
1296
  }
@@ -1311,7 +1298,7 @@ function diff(nativeRenderer, newAtom, oldAtom, context, expectIndex, index) {
1311
1298
  linkTemplate(newTemplate, newAtom.jsxNode, newAtom);
1312
1299
  }
1313
1300
  if (newAtom.child) {
1314
- diff(nativeRenderer, newAtom.child, reusedAtom.child, context, expectIndex, diffIndex);
1301
+ diff(nativeRenderer, instance, newAtom.child, reusedAtom.child, context, expectIndex, diffIndex);
1315
1302
  }
1316
1303
  else if (reusedAtom.child) {
1317
1304
  let atom = reusedAtom.child;
@@ -1320,7 +1307,7 @@ function diff(nativeRenderer, newAtom, oldAtom, context, expectIndex, index) {
1320
1307
  atom = atom.sibling;
1321
1308
  }
1322
1309
  }
1323
- newAtom.jsxNode.rendered();
1310
+ oldJSXComponent.reset();
1324
1311
  });
1325
1312
  },
1326
1313
  updateElement: (newAtom, oldAtom, expectIndex, oldIndex) => {
@@ -1339,7 +1326,7 @@ function diff(nativeRenderer, newAtom, oldAtom, context, expectIndex, index) {
1339
1326
  context.isParent = false;
1340
1327
  const applyRefs = updateNativeNodeProperties(nativeRenderer, newAtom.jsxNode, oldAtom.jsxNode, newAtom.nativeNode);
1341
1328
  if (newAtom.child) {
1342
- diff(nativeRenderer, newAtom.child, oldAtom.child, {
1329
+ diff(nativeRenderer, parentComponent, newAtom.child, oldAtom.child, {
1343
1330
  host: newAtom.nativeNode,
1344
1331
  isParent: true
1345
1332
  }, 0, 0);
@@ -1367,7 +1354,7 @@ function diff(nativeRenderer, newAtom, oldAtom, context, expectIndex, index) {
1367
1354
  },
1368
1355
  create: (start) => {
1369
1356
  commits.push(() => {
1370
- buildView(nativeRenderer, start, context);
1357
+ buildView(nativeRenderer, parentComponent, start, context);
1371
1358
  });
1372
1359
  }
1373
1360
  };
@@ -1406,7 +1393,7 @@ function reuseComponentView(nativeRenderer, newAtom, reusedAtom, context, moveVi
1406
1393
  child = child.sibling;
1407
1394
  }
1408
1395
  const updateContext = (atom) => {
1409
- if (atom.jsxNode instanceof Component) {
1396
+ if (atom.jsxNode instanceof JSXComponent) {
1410
1397
  let child = atom.child;
1411
1398
  while (child) {
1412
1399
  updateContext(child);
@@ -1472,30 +1459,29 @@ function cleanView(nativeRenderer, atom, isClean) {
1472
1459
  cleanView(nativeRenderer, child, isClean);
1473
1460
  child = child.sibling;
1474
1461
  }
1475
- if (atom.jsxNode instanceof Component) {
1476
- atom.jsxNode.destroy();
1462
+ if (atom.jsxNode instanceof JSXComponent) {
1463
+ atom.jsxNode.instance.destroy();
1477
1464
  }
1478
1465
  }
1479
- function componentRender(component, from, context) {
1480
- const { template, render } = component.setup();
1466
+ function componentRender(jsxComponent, parentComponent, from, context) {
1467
+ const component = jsxComponent.createInstance(parentComponent);
1468
+ const template = component.render();
1481
1469
  if (template) {
1482
- linkTemplate(template, component, from);
1470
+ linkTemplate(template, jsxComponent, from);
1483
1471
  }
1484
- component.$$view = Object.assign({ render,
1485
- template, atom: from }, context);
1486
- return from;
1472
+ jsxComponent.$$view = Object.assign({ atom: from }, context);
1473
+ return component;
1487
1474
  }
1488
- function createChainByComponentFactory(context, factory, parent) {
1489
- const component = factory.createInstance(context);
1475
+ function createChainByComponentFactory(jsxComponent, parent) {
1490
1476
  return {
1491
- jsxNode: component,
1477
+ jsxNode: jsxComponent,
1492
1478
  parent,
1493
1479
  sibling: null,
1494
1480
  child: null,
1495
1481
  nativeNode: null
1496
1482
  };
1497
1483
  }
1498
- function createChainByJSXElement(context, element, parent) {
1484
+ function createChainByJSXElement(jsxComponent, element, parent) {
1499
1485
  const atom = {
1500
1486
  jsxNode: element,
1501
1487
  parent,
@@ -1505,7 +1491,7 @@ function createChainByJSXElement(context, element, parent) {
1505
1491
  };
1506
1492
  if (Reflect.has(element.props, 'children')) {
1507
1493
  const jsxChildren = element.props.children;
1508
- const children = createChainByChildren(context, Array.isArray(jsxChildren) ? jsxChildren : [jsxChildren], atom, []);
1494
+ const children = createChainByChildren(jsxComponent, Array.isArray(jsxChildren) ? jsxChildren : [jsxChildren], atom, []);
1509
1495
  link(atom, children);
1510
1496
  }
1511
1497
  return atom;
@@ -1519,14 +1505,14 @@ function createChainByJSXText(node, parent) {
1519
1505
  nativeNode: null
1520
1506
  };
1521
1507
  }
1522
- function createChainByChildren(context, children, parent, atoms) {
1508
+ function createChainByChildren(jsxComponent, children, parent, atoms) {
1523
1509
  for (const item of children) {
1524
1510
  if (item instanceof JSXElement) {
1525
- atoms.push(createChainByJSXElement(context, item, parent));
1511
+ atoms.push(createChainByJSXElement(jsxComponent, item, parent));
1526
1512
  continue;
1527
1513
  }
1528
1514
  if (item instanceof JSXComponent) {
1529
- const childAtom = createChainByComponentFactory(context, item, parent);
1515
+ const childAtom = createChainByComponentFactory(item, parent);
1530
1516
  atoms.push(childAtom);
1531
1517
  continue;
1532
1518
  }
@@ -1535,7 +1521,7 @@ function createChainByChildren(context, children, parent, atoms) {
1535
1521
  continue;
1536
1522
  }
1537
1523
  if (Array.isArray(item)) {
1538
- createChainByChildren(context, item, parent, atoms);
1524
+ createChainByChildren(jsxComponent, item, parent, atoms);
1539
1525
  continue;
1540
1526
  }
1541
1527
  if (item !== null && typeof item !== 'undefined') {
@@ -1544,9 +1530,10 @@ function createChainByChildren(context, children, parent, atoms) {
1544
1530
  }
1545
1531
  return atoms;
1546
1532
  }
1547
- function linkTemplate(template, component, parent) {
1533
+ function linkTemplate(template, jsxComponent, parent) {
1548
1534
  const children = Array.isArray(template) ? template : [template];
1549
- link(parent, createChainByChildren(component, children, parent, []));
1535
+ const newChildren = createChainByChildren(jsxComponent, children, parent, []);
1536
+ link(parent, newChildren);
1550
1537
  }
1551
1538
  function link(parent, children) {
1552
1539
  for (let i = 1; i < children.length; i++) {
@@ -1726,17 +1713,37 @@ function bindEvent(nativeRenderer, vNode, key, nativeNode, listenFn) {
1726
1713
  nativeRenderer.listen(nativeNode, type, delegate);
1727
1714
  }
1728
1715
 
1716
+ /**
1717
+ * Viewfly 根组件,用于实现组件状态更新事件通知
1718
+ */
1719
+ class RootComponent extends JSXComponent {
1720
+ constructor(factory, {}) {
1721
+ super(factory, {}, (parentComponent, jsxNode) => {
1722
+ return new Component(parentComponent, jsxNode, {});
1723
+ });
1724
+ this.onChange = null;
1725
+ }
1726
+ markAsChanged(changedComponent) {
1727
+ var _a;
1728
+ this._changed = true;
1729
+ if (changedComponent) {
1730
+ this.changedSubComponents.add(changedComponent);
1731
+ }
1732
+ (_a = this.onChange) === null || _a === void 0 ? void 0 : _a.call(this);
1733
+ }
1734
+ }
1735
+
1729
1736
  const viewflyErrorFn = makeError('Viewfly');
1730
1737
  function viewfly({ context, nativeRenderer, autoUpdate, root }) {
1731
1738
  const appProviders = [];
1732
1739
  let destroyed = false;
1733
- const rootComponent = new RootComponent(context || null, () => {
1740
+ const rootComponent = new RootComponent(() => {
1734
1741
  provide(appProviders);
1735
1742
  return () => {
1736
1743
  return destroyed ? null : root;
1737
1744
  };
1738
- });
1739
- const render = createRenderer(rootComponent, nativeRenderer);
1745
+ }, {});
1746
+ const render = createRenderer(rootComponent, nativeRenderer, context || new NullInjector());
1740
1747
  let isStarted = false;
1741
1748
  let task = null;
1742
1749
  function microTask(callback) {