@viewfly/core 1.0.0-alpha.1 → 1.0.0-alpha.11

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/bundles/index.js CHANGED
@@ -163,6 +163,40 @@ exports.InjectFlags = void 0;
163
163
  class Injector {
164
164
  }
165
165
 
166
+ /**
167
+ * 构造函数参数装饰器,用于改变注入 token
168
+ */
169
+ const Inject = function InjectDecorator(token) {
170
+ if (this instanceof Inject) {
171
+ this.token = token;
172
+ }
173
+ else {
174
+ return makeParamDecorator(Inject, new Inject(token));
175
+ }
176
+ };
177
+ const Self = function SelfDecorator() {
178
+ if (!(this instanceof Self)) {
179
+ return makeParamDecorator(Self, new Self());
180
+ }
181
+ };
182
+ const SkipSelf = function SkipSelfDecorator() {
183
+ if (!(this instanceof SkipSelf)) {
184
+ return makeParamDecorator(SkipSelf, new SkipSelf());
185
+ }
186
+ };
187
+ const Optional = function OptionalDecorator() {
188
+ if (!(this instanceof Optional)) {
189
+ return makeParamDecorator(Optional, new Optional());
190
+ }
191
+ };
192
+ const Prop = function PropDecorator(token, notFoundValue, flags) {
193
+ if (!(this instanceof Prop)) {
194
+ return makePropertyDecorator(Prop, token, function (instance, propertyName, token, injector) {
195
+ instance[propertyName] = injector.get(token instanceof ForwardRef ? token.getRef() : token, notFoundValue, flags);
196
+ });
197
+ }
198
+ };
199
+
166
200
  function stringify(token) {
167
201
  if (typeof token === 'string') {
168
202
  return token;
@@ -207,7 +241,8 @@ class NullInjector extends Injector {
207
241
  super(...arguments);
208
242
  this.parentInjector = null;
209
243
  }
210
- get(token, flag, notFoundValue = THROW_IF_NOT_FOUND) {
244
+ /* eslint-disable-next-line */
245
+ get(token, notFoundValue = THROW_IF_NOT_FOUND, _) {
211
246
  if (notFoundValue === THROW_IF_NOT_FOUND) {
212
247
  throw nullInjectorErrorFn(token);
213
248
  }
@@ -215,40 +250,6 @@ class NullInjector extends Injector {
215
250
  }
216
251
  }
217
252
 
218
- /**
219
- * 构造函数参数装饰器,用于改变注入 token
220
- */
221
- const Inject = function InjectDecorator(token) {
222
- if (this instanceof Inject) {
223
- this.token = token;
224
- }
225
- else {
226
- return makeParamDecorator(Inject, new Inject(token));
227
- }
228
- };
229
- const Self = function SelfDecorator() {
230
- if (!(this instanceof Self)) {
231
- return makeParamDecorator(Self, new Self());
232
- }
233
- };
234
- const SkipSelf = function SkipSelfDecorator() {
235
- if (!(this instanceof SkipSelf)) {
236
- return makeParamDecorator(SkipSelf, new SkipSelf());
237
- }
238
- };
239
- const Optional = function OptionalDecorator() {
240
- if (!(this instanceof Optional)) {
241
- return makeParamDecorator(Optional, new Optional());
242
- }
243
- };
244
- const Prop = function PropDecorator(token, flags, notFoundValue = THROW_IF_NOT_FOUND) {
245
- if (!(this instanceof Prop)) {
246
- return makePropertyDecorator(Prop, token, function (instance, propertyName, token, injector) {
247
- instance[propertyName] = injector.get(token instanceof ForwardRef ? token.getRef() : token, flags, notFoundValue);
248
- });
249
- }
250
- };
251
-
252
253
  /**
253
254
  * 标准化 provide,并返回统一数据结构
254
255
  * @param provider
@@ -426,15 +427,15 @@ class ReflectiveInjector extends Injector {
426
427
  /**
427
428
  * 用于获取当前注入器上下文内的实例、对象或数据
428
429
  * @param token 访问 token
429
- * @param flags 查询规则
430
430
  * @param notFoundValue 如未查找到的返回值
431
+ * @param flags 查询规则
431
432
  */
432
- get(token, flags = exports.InjectFlags.Default, notFoundValue = THROW_IF_NOT_FOUND) {
433
+ get(token, notFoundValue = THROW_IF_NOT_FOUND, flags) {
433
434
  var _a;
434
435
  flags = flags || exports.InjectFlags.Default;
435
436
  if (flags === exports.InjectFlags.SkipSelf) {
436
437
  if (this.parentInjector) {
437
- return this.parentInjector.get(token, exports.InjectFlags.Default, notFoundValue);
438
+ return this.parentInjector.get(token, notFoundValue);
438
439
  }
439
440
  if (notFoundValue !== THROW_IF_NOT_FOUND) {
440
441
  return notFoundValue;
@@ -478,9 +479,12 @@ class ReflectiveInjector extends Injector {
478
479
  return notFoundValue;
479
480
  }
480
481
  if (this.parentInjector) {
481
- return this.parentInjector.get(token, flags === exports.InjectFlags.Optional ? exports.InjectFlags.Optional : exports.InjectFlags.Default, notFoundValue);
482
+ return this.parentInjector.get(token, notFoundValue, flags === exports.InjectFlags.Optional ? exports.InjectFlags.Optional : exports.InjectFlags.Default);
482
483
  }
483
484
  if (notFoundValue === THROW_IF_NOT_FOUND) {
485
+ // if (flags === InjectFlags.Optional) {
486
+ // return null as U
487
+ // }
484
488
  throw reflectiveInjectorErrorFn(token);
485
489
  }
486
490
  return notFoundValue;
@@ -510,11 +514,11 @@ class ReflectiveInjector extends Injector {
510
514
  const tryValue = {};
511
515
  const injectToken = dep.injectKey instanceof ForwardRef ? dep.injectKey.getRef() : dep.injectKey;
512
516
  if (dep.visibility instanceof Self) {
513
- reflectiveValue = this.get(injectToken, exports.InjectFlags.Self, tryValue);
517
+ reflectiveValue = this.get(injectToken, tryValue, exports.InjectFlags.Self);
514
518
  }
515
519
  else if (dep.visibility instanceof SkipSelf) {
516
520
  if (this.parentInjector) {
517
- reflectiveValue = this.parentInjector.get(injectToken, exports.InjectFlags.Default, tryValue);
521
+ reflectiveValue = this.parentInjector.get(injectToken, tryValue);
518
522
  }
519
523
  else {
520
524
  if (dep.optional) {
@@ -527,7 +531,7 @@ class ReflectiveInjector extends Injector {
527
531
  }
528
532
  }
529
533
  else {
530
- reflectiveValue = this.get(injectToken, exports.InjectFlags.Default, tryValue);
534
+ reflectiveValue = this.get(injectToken, tryValue);
531
535
  }
532
536
  if (reflectiveValue === tryValue) {
533
537
  if (dep.optional) {
@@ -589,13 +593,13 @@ function getArrayChanges(left, right) {
589
593
  return changes;
590
594
  }
591
595
  function classToString(config) {
592
- if (!config) {
593
- return '';
594
- }
595
596
  if (typeof config === 'string') {
596
597
  return config;
597
598
  }
598
- else if (Array.isArray(config)) {
599
+ if (!config) {
600
+ return '';
601
+ }
602
+ if (Array.isArray(config)) {
599
603
  const classes = [];
600
604
  for (const i of config) {
601
605
  const v = classToString(i);
@@ -605,7 +609,7 @@ function classToString(config) {
605
609
  }
606
610
  return classes.join(' ');
607
611
  }
608
- else if (typeof config === 'object') {
612
+ if (typeof config === 'object') {
609
613
  if (config.toString !== Object.prototype.toString && !config.toString.toString().includes('[native code]')) {
610
614
  return config.toString();
611
615
  }
@@ -739,30 +743,32 @@ class Component extends ReflectiveInjector {
739
743
  };
740
744
  }
741
745
  update(newProps, forceUpdate = false) {
742
- const oldProps = this.props;
743
- const { add, remove, replace } = getObjectChanges(newProps, this.props);
744
- if (add.length || remove.length || replace.length) {
745
- this.invokePropsChangedHooks(newProps);
746
- }
747
- else if (!this.dirty) {
748
- return this.template;
749
- }
750
- const newRefs = toRefs(newProps.ref);
751
- if (this.refs) {
752
- for (const oldRef of this.refs) {
753
- if (!newRefs.includes(oldRef)) {
754
- oldRef.unBind(this.instance);
746
+ if (!forceUpdate) {
747
+ const { add, remove, replace } = getObjectChanges(newProps, this.props);
748
+ if (add.length || remove.length || replace.length) {
749
+ this.invokePropsChangedHooks(newProps);
750
+ }
751
+ else if (!this.dirty) {
752
+ this.props = newProps;
753
+ return this.template;
754
+ }
755
+ const newRefs = toRefs(newProps.ref);
756
+ if (this.refs) {
757
+ for (const oldRef of this.refs) {
758
+ if (!newRefs.includes(oldRef)) {
759
+ oldRef.unBind(this.instance);
760
+ }
755
761
  }
756
762
  }
763
+ for (const newRef of newRefs) {
764
+ newRef.bind(this.instance);
765
+ }
766
+ if (newRefs.length) {
767
+ this.refs = newRefs;
768
+ }
757
769
  }
758
- for (const newRef of newRefs) {
759
- newRef.bind(this.instance);
760
- }
761
- if (newRefs.length) {
762
- this.refs = newRefs;
763
- }
764
- if (!forceUpdate && typeof this.instance.$useMemo === 'function') {
765
- if (this.instance.$useMemo(newProps, oldProps)) {
770
+ if (typeof this.instance.$useMemo === 'function') {
771
+ if (this.instance.$useMemo(newProps, this.props)) {
766
772
  return this.template;
767
773
  }
768
774
  }
@@ -845,7 +851,12 @@ class Component extends ReflectiveInjector {
845
851
  }
846
852
  }
847
853
  if (unmountedCallbacks.length) {
848
- this.unmountedCallbacks = unmountedCallbacks;
854
+ if (this.unmountedCallbacks) {
855
+ this.unmountedCallbacks.push(...unmountedCallbacks);
856
+ }
857
+ else {
858
+ this.unmountedCallbacks = unmountedCallbacks;
859
+ }
849
860
  }
850
861
  this.mountCallbacks = null;
851
862
  }
@@ -1234,9 +1245,9 @@ function withAnnotation(annotation, componentSetup) {
1234
1245
  /**
1235
1246
  * 通过组件上下文获取 IoC 容器内数据的勾子方法
1236
1247
  */
1237
- function inject(token, flags = exports.InjectFlags.Default, notFoundValue = THROW_IF_NOT_FOUND) {
1248
+ function inject(token, notFoundValue = THROW_IF_NOT_FOUND, flags) {
1238
1249
  const component = getSetupContext();
1239
- return component.get(token, flags, notFoundValue);
1250
+ return component.get(token, notFoundValue, flags);
1240
1251
  }
1241
1252
  /**
1242
1253
  * 获取当前组件实例
@@ -1274,6 +1285,7 @@ function withMemo(canUseMemo, render) {
1274
1285
  };
1275
1286
  }
1276
1287
 
1288
+ const componentViewCache = new WeakMap();
1277
1289
  const listenerReg = /^on(?=[A-Z])/;
1278
1290
  function createRenderer(component, nativeRenderer) {
1279
1291
  let isInit = true;
@@ -1282,6 +1294,7 @@ function createRenderer(component, nativeRenderer) {
1282
1294
  isInit = false;
1283
1295
  const atom = {
1284
1296
  type: 'component',
1297
+ index: 0,
1285
1298
  jsxNode: component,
1286
1299
  sibling: null,
1287
1300
  child: null,
@@ -1351,7 +1364,7 @@ function updateView(nativeRenderer, component) {
1351
1364
  }
1352
1365
  }
1353
1366
  function applyChanges(nativeRenderer, component) {
1354
- const { atom, host, isParent, rootHost } = component.$$view;
1367
+ const { atom, host, isParent, rootHost } = componentViewCache.get(component);
1355
1368
  const diffAtom = atom.child;
1356
1369
  const template = component.update(component.props, true);
1357
1370
  atom.child = createChildChain(template, atom.isSvg);
@@ -1360,58 +1373,35 @@ function applyChanges(nativeRenderer, component) {
1360
1373
  isParent,
1361
1374
  rootHost
1362
1375
  };
1363
- diff(nativeRenderer, component, atom.child, diffAtom, context, 0, 0);
1376
+ diff(nativeRenderer, component, atom.child, diffAtom, context);
1364
1377
  const next = atom.sibling;
1365
1378
  if (next && next.jsxNode instanceof Component) {
1366
- next.jsxNode.$$view.host = context.host;
1367
- next.jsxNode.$$view.isParent = context.isParent;
1368
- }
1369
- }
1370
- function diff(nativeRenderer, parentComponent, newAtom, oldAtom, context, expectIndex, index) {
1371
- let prevDiffAtom = null;
1372
- let firstDiffAtomIndexed = null;
1373
- if (oldAtom) {
1374
- prevDiffAtom = {
1375
- index,
1376
- atom: oldAtom,
1377
- prev: null
1378
- };
1379
- index++;
1380
- firstDiffAtomIndexed = prevDiffAtom;
1381
- oldAtom = oldAtom.sibling;
1382
- while (oldAtom) {
1383
- const diffAtom = {
1384
- index,
1385
- atom: oldAtom,
1386
- prev: prevDiffAtom
1387
- };
1388
- prevDiffAtom.next = diffAtom;
1389
- prevDiffAtom = diffAtom;
1390
- oldAtom = oldAtom.sibling;
1391
- index++;
1392
- }
1379
+ const view = componentViewCache.get(next.jsxNode);
1380
+ view.host = context.host;
1381
+ view.isParent = context.isParent;
1393
1382
  }
1383
+ }
1384
+ function diff(nativeRenderer, parentComponent, newAtom, oldAtom, context) {
1394
1385
  const commits = [];
1395
1386
  function changeOffset() {
1396
1387
  offset++;
1397
1388
  }
1398
1389
  while (newAtom) {
1399
- firstDiffAtomIndexed = createChanges(newAtom, expectIndex, firstDiffAtomIndexed, nativeRenderer, commits, context, parentComponent, changeOffset);
1390
+ oldAtom = createChanges(newAtom, oldAtom, nativeRenderer, commits, context, parentComponent, changeOffset);
1400
1391
  newAtom = newAtom.sibling;
1401
- expectIndex++;
1402
1392
  }
1403
- let dirtyDiffAtom = firstDiffAtomIndexed;
1393
+ let dirtyDiffAtom = oldAtom;
1404
1394
  while (dirtyDiffAtom) {
1405
- cleanView(nativeRenderer, dirtyDiffAtom.atom, false);
1406
- dirtyDiffAtom = dirtyDiffAtom.next;
1395
+ cleanView(nativeRenderer, dirtyDiffAtom, true);
1396
+ dirtyDiffAtom = dirtyDiffAtom.sibling;
1407
1397
  }
1408
1398
  let offset = 0;
1409
1399
  for (let i = 0; i < commits.length; i++) {
1410
1400
  const commit = commits[i];
1411
- while (firstDiffAtomIndexed) {
1412
- if (firstDiffAtomIndexed.index <= i) {
1401
+ while (oldAtom) {
1402
+ if (oldAtom.index <= i) {
1413
1403
  offset--;
1414
- firstDiffAtomIndexed = firstDiffAtomIndexed.next;
1404
+ oldAtom = oldAtom.sibling;
1415
1405
  continue;
1416
1406
  }
1417
1407
  break;
@@ -1419,47 +1409,42 @@ function diff(nativeRenderer, parentComponent, newAtom, oldAtom, context, expect
1419
1409
  commit(offset);
1420
1410
  }
1421
1411
  }
1422
- function createChanges(newAtom, expectIndex, diffAtomIndexed, nativeRenderer, commits, context, parentComponent, effect) {
1423
- const startDiffAtom = diffAtomIndexed;
1412
+ function createChanges(newAtom, oldAtom, nativeRenderer, commits, context, parentComponent, effect) {
1413
+ const startDiffAtom = oldAtom;
1424
1414
  const { jsxNode: newJsxNode, type } = newAtom;
1425
1415
  const key = newJsxNode.key;
1426
- while (diffAtomIndexed) {
1427
- const { atom: diffAtom, index: diffIndex } = diffAtomIndexed;
1428
- if (type === diffAtom.type) {
1416
+ let prev = null;
1417
+ while (oldAtom) {
1418
+ const diffIndex = oldAtom.index;
1419
+ if (type === oldAtom.type) {
1429
1420
  let commit;
1430
1421
  if (type === 'text') {
1431
- commit = updateText(newAtom, diffAtom, nativeRenderer, context);
1422
+ commit = updateText(newAtom, oldAtom, nativeRenderer, context);
1432
1423
  }
1433
1424
  else {
1434
- const { key: diffKey, type: diffType } = diffAtom.jsxNode;
1425
+ const { key: diffKey, type: diffType } = oldAtom.jsxNode;
1435
1426
  if (diffKey !== key || newJsxNode.type !== diffType) {
1436
- diffAtomIndexed = diffAtomIndexed.next;
1427
+ prev = oldAtom;
1428
+ oldAtom = oldAtom.sibling;
1437
1429
  continue;
1438
1430
  }
1439
1431
  if (type === 'component') {
1440
- commit = updateComponent(newAtom, diffAtom, expectIndex, diffIndex, nativeRenderer, context);
1432
+ commit = updateComponent(newAtom, oldAtom, newAtom.index, diffIndex, nativeRenderer, context);
1441
1433
  }
1442
1434
  else {
1443
- commit = updateElement(newAtom, diffAtom, expectIndex, diffIndex, nativeRenderer, context, parentComponent);
1435
+ commit = updateElement(newAtom, oldAtom, newAtom.index, diffIndex, nativeRenderer, context, parentComponent);
1444
1436
  }
1445
1437
  }
1446
1438
  commits.push(commit);
1447
- const next = diffAtomIndexed.next;
1448
- const prev = diffAtomIndexed.prev;
1439
+ const next = oldAtom.sibling;
1449
1440
  if (!prev) {
1450
- diffAtomIndexed = next;
1451
- if (diffAtomIndexed) {
1452
- diffAtomIndexed.prev = null;
1453
- }
1454
- return diffAtomIndexed;
1455
- }
1456
- prev.next = next;
1457
- if (next) {
1458
- next.prev = prev;
1441
+ return next;
1459
1442
  }
1443
+ prev.sibling = next;
1460
1444
  return startDiffAtom;
1461
1445
  }
1462
- diffAtomIndexed = diffAtomIndexed.next;
1446
+ prev = oldAtom;
1447
+ oldAtom = oldAtom.sibling;
1463
1448
  }
1464
1449
  commits.push(createNewView(newAtom, nativeRenderer, context, parentComponent, effect));
1465
1450
  return startDiffAtom;
@@ -1495,13 +1480,13 @@ function updateElement(newAtom, oldAtom, expectIndex, oldIndex, nativeRenderer,
1495
1480
  host: newAtom.nativeNode,
1496
1481
  isParent: true,
1497
1482
  rootHost: context.rootHost
1498
- }, 0, 0);
1483
+ });
1499
1484
  }
1500
1485
  else if (oldAtom.child) {
1501
1486
  let atom = oldAtom.child;
1502
1487
  nativeRenderer.cleanChildren(oldAtom.nativeNode, oldAtom.isSvg);
1503
1488
  while (atom) {
1504
- cleanView(nativeRenderer, atom, true);
1489
+ cleanView(nativeRenderer, atom, false);
1505
1490
  atom = atom.sibling;
1506
1491
  }
1507
1492
  }
@@ -1516,7 +1501,7 @@ function updateComponent(newAtom, reusedAtom, expectIndex, oldIndex, nativeRende
1516
1501
  const newTemplate = component.update(newProps);
1517
1502
  const portalHost = component.instance.$portalHost;
1518
1503
  context = portalHost ? { isParent: true, host: portalHost, rootHost: portalHost } : context;
1519
- component.$$view = Object.assign({ atom: newAtom }, context);
1504
+ componentViewCache.set(component, Object.assign({ atom: newAtom }, context));
1520
1505
  newAtom.jsxNode = component;
1521
1506
  if (newTemplate === oldTemplate) {
1522
1507
  reuseComponentView(nativeRenderer, newAtom, reusedAtom, context, expectIndex - offset !== oldIndex);
@@ -1527,12 +1512,12 @@ function updateComponent(newAtom, reusedAtom, expectIndex, oldIndex, nativeRende
1527
1512
  newAtom.child = createChildChain(newTemplate, newAtom.isSvg);
1528
1513
  }
1529
1514
  if (newAtom.child) {
1530
- diff(nativeRenderer, component, newAtom.child, reusedAtom.child, context, expectIndex, oldIndex + offset);
1515
+ diff(nativeRenderer, component, newAtom.child, reusedAtom.child, context);
1531
1516
  }
1532
1517
  else if (reusedAtom.child) {
1533
1518
  let atom = reusedAtom.child;
1534
1519
  while (atom) {
1535
- cleanView(nativeRenderer, atom, false);
1520
+ cleanView(nativeRenderer, atom, true);
1536
1521
  atom = atom.sibling;
1537
1522
  }
1538
1523
  }
@@ -1565,9 +1550,9 @@ function reuseComponentView(nativeRenderer, newAtom, reusedAtom, context, moveVi
1565
1550
  }
1566
1551
  function cleanView(nativeRenderer, atom, needClean) {
1567
1552
  if (atom.nativeNode) {
1568
- if (!needClean) {
1553
+ if (needClean) {
1569
1554
  nativeRenderer.remove(atom.nativeNode, atom.isSvg);
1570
- needClean = true;
1555
+ needClean = false;
1571
1556
  }
1572
1557
  if (atom.type === 'element') {
1573
1558
  const ref = atom.jsxNode.props[refKey];
@@ -1577,7 +1562,7 @@ function cleanView(nativeRenderer, atom, needClean) {
1577
1562
  let child = atom.child;
1578
1563
  while (child) {
1579
1564
  if (child.jsxNode instanceof Component && child.jsxNode.instance.$portalHost) {
1580
- needClean = false;
1565
+ needClean = true;
1581
1566
  }
1582
1567
  cleanView(nativeRenderer, child, needClean);
1583
1568
  child = child.sibling;
@@ -1590,7 +1575,7 @@ function componentRender(nativeRenderer, component, from, context) {
1590
1575
  const { template, portalHost } = component.render();
1591
1576
  from.child = createChildChain(template, from.isSvg);
1592
1577
  context = portalHost ? { isParent: true, host: portalHost, rootHost: portalHost } : context;
1593
- component.$$view = Object.assign({ atom: from }, context);
1578
+ componentViewCache.set(component, Object.assign({ atom: from }, context));
1594
1579
  let child = from.child;
1595
1580
  while (child) {
1596
1581
  buildView(nativeRenderer, component, child, context);
@@ -1601,6 +1586,7 @@ function componentRender(nativeRenderer, component, from, context) {
1601
1586
  function createChainByJSXComponent(jsxNode, prevAtom, isSvg) {
1602
1587
  const atom = {
1603
1588
  type: 'component',
1589
+ index: prevAtom.index + 1,
1604
1590
  jsxNode,
1605
1591
  sibling: null,
1606
1592
  child: null,
@@ -1613,6 +1599,7 @@ function createChainByJSXComponent(jsxNode, prevAtom, isSvg) {
1613
1599
  function createChainByJSXText(jsxNode, prevAtom, isSvg) {
1614
1600
  const atom = {
1615
1601
  type: 'text',
1602
+ index: prevAtom.index + 1,
1616
1603
  jsxNode,
1617
1604
  sibling: null,
1618
1605
  child: null,
@@ -1626,6 +1613,7 @@ function createChainByJSXElement(element, prevAtom, isSvg) {
1626
1613
  isSvg = isSvg || element.type === 'svg';
1627
1614
  const atom = {
1628
1615
  type: 'element',
1616
+ index: prevAtom.index + 1,
1629
1617
  jsxNode: element,
1630
1618
  sibling: null,
1631
1619
  child: null,
@@ -1665,7 +1653,7 @@ function createChainByChildren(children, prevAtom, isSvg) {
1665
1653
  return prevAtom;
1666
1654
  }
1667
1655
  function createChildChain(template, isSvg) {
1668
- const beforeAtom = { sibling: null };
1656
+ const beforeAtom = { sibling: null, index: -1 };
1669
1657
  createChainByNode(template, beforeAtom, isSvg);
1670
1658
  return beforeAtom.sibling;
1671
1659
  }
@@ -1728,6 +1716,11 @@ function createTextNode(nativeRenderer, text, isSvg) {
1728
1716
  return nativeRenderer.createTextNode(text, isSvg);
1729
1717
  }
1730
1718
  function updateNativeNodeProperties(nativeRenderer, newVNode, oldVNode, nativeNode, isSvg) {
1719
+ if (newVNode === oldVNode) {
1720
+ return () => {
1721
+ //
1722
+ };
1723
+ }
1731
1724
  const changes = getObjectChanges(newVNode.props, oldVNode.props);
1732
1725
  let unBindRefs;
1733
1726
  let bindRefs;
@@ -1886,7 +1879,7 @@ function viewfly(config) {
1886
1879
  return destroyed ? null : root;
1887
1880
  };
1888
1881
  }), function () {
1889
- if (destroyed) {
1882
+ if (destroyed || !autoUpdate) {
1890
1883
  return;
1891
1884
  }
1892
1885
  nextTick(() => {
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@viewfly/core",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-alpha.11",
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",
7
- "typings": "./bundles/public-api.d.ts",
7
+ "typings": "./bundles/index.d.ts",
8
8
  "exports": {
9
9
  ".": {
10
- "types": "./bundles/public-api.d.ts",
10
+ "types": "./bundles/index.d.ts",
11
11
  "import": "./bundles/index.esm.js",
12
12
  "require": "./bundles/index.js"
13
13
  },
@@ -23,7 +23,9 @@
23
23
  }
24
24
  },
25
25
  "scripts": {
26
- "build:lib": "rimraf bundles && rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript",
26
+ "build:lib": "rimraf bundles && npm run build && npm run build-d",
27
+ "build": "rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript",
28
+ "build-d": "rollup --config rollup-d.config.ts --configPlugin @rollup/plugin-typescript",
27
29
  "publish:lib": "npm run build:lib && npm publish --access=public"
28
30
  },
29
31
  "license": "MIT",
@@ -34,6 +36,7 @@
34
36
  "@rollup/plugin-typescript": "^11.1.2",
35
37
  "rimraf": "^3.0.2",
36
38
  "rollup": "^3.26.3",
39
+ "rollup-plugin-dts": "^6.1.1",
37
40
  "tslib": "^2.6.0"
38
41
  },
39
42
  "author": {
@@ -47,8 +50,8 @@
47
50
  "bugs": {
48
51
  "url": "https://github.com/viewfly/viewfly.git/issues"
49
52
  },
50
- "gitHead": "8a25e6e350ba9cade6036506e7fe2aba4e4396ac",
53
+ "gitHead": "723da75a9e8e13e8addbe4646358667f476e06f3",
51
54
  "dependencies": {
52
- "reflect-metadata": "^0.1.13"
55
+ "reflect-metadata": "^0.2.2"
53
56
  }
54
57
  }
@@ -0,0 +1,14 @@
1
+ import dts from 'rollup-plugin-dts'
2
+
3
+ export default {
4
+ input: 'src/public-api.ts',
5
+ output: [
6
+ {
7
+ file: './bundles/index.d.ts',
8
+ format: 'es'
9
+ }
10
+ ],
11
+ plugins: [
12
+ dts(),
13
+ ]
14
+ }
@@ -1 +0,0 @@
1
- export declare function makeError(name: string): (message: string) => Error;
@@ -1,10 +0,0 @@
1
- export * from './forward-ref';
2
- export * from './injectable';
3
- export * from './injection-token';
4
- export * from './injector';
5
- export * from './metadata';
6
- export * from './null-injector';
7
- export * from './provider';
8
- export * from './reflective-injector';
9
- export * from './reflective-provider';
10
- export * from './type';
@@ -1,10 +0,0 @@
1
- export declare class ForwardRef<T = any> {
2
- private forwardRefFn;
3
- constructor(forwardRefFn: () => T);
4
- getRef(): T;
5
- }
6
- /**
7
- * 引用后声明的类的工具函数
8
- * @param fn
9
- */
10
- export declare function forwardRef<T>(fn: () => T): ForwardRef<T>;
@@ -1,20 +0,0 @@
1
- export declare class Scope {
2
- name: string;
3
- constructor(name: string);
4
- toString(): string;
5
- }
6
- export type ProvideScope = 'root' | Scope;
7
- export interface InjectableOptions {
8
- provideIn: ProvideScope;
9
- }
10
- export interface Injectable {
11
- provideIn?: ProvideScope;
12
- }
13
- export interface InjectableDecorator {
14
- (options?: InjectableOptions): ClassDecorator;
15
- new (options?: InjectableOptions): Injectable;
16
- }
17
- /**
18
- * 可注入类的装饰器
19
- */
20
- export declare const Injectable: InjectableDecorator;
@@ -1,8 +0,0 @@
1
- /**
2
- * 生成自定义依赖注入 token 的类
3
- */
4
- export declare class InjectionToken<T> {
5
- readonly description: string;
6
- constructor(description: string);
7
- toString(): string;
8
- }
@@ -1,26 +0,0 @@
1
- import { AbstractType, Type } from './type';
2
- import { InjectionToken } from './injection-token';
3
- /**
4
- * 查找规则
5
- */
6
- export declare enum InjectFlags {
7
- /** 默认查找规则 */
8
- Default = "Default",
9
- /** 锁定当前容器 */
10
- Self = "Self",
11
- /** 跳过当前容器 */
12
- SkipSelf = "SkipSelf",
13
- /** 可选查找 */
14
- Optional = "Optional"
15
- }
16
- /**
17
- * 根据 token 推断返回数据类型
18
- */
19
- export type ExtractValueType<T> = T extends Type<any> ? InstanceType<T> : T extends AbstractType<infer K> ? K : T extends InjectionToken<infer V> ? V : never;
20
- /**
21
- * DI 容器抽象基类
22
- */
23
- export declare abstract class Injector {
24
- abstract parentInjector: Injector | null;
25
- abstract get<T extends Type<any> | AbstractType<any> | InjectionToken<any>, U = never>(token: T, flags?: InjectFlags, notFoundValue?: U): ExtractValueType<T> | U;
26
- }