targetj 1.0.260 → 1.1.1

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.
@@ -28,7 +28,7 @@ import { TargetData } from "./TargetData.js";
28
28
  import { TModelUtil } from "./TModelUtil.js";
29
29
  import { ScheduleUtil } from "./ScheduleUtil.js";
30
30
  import { TargetExecutor } from "./TargetExecutor.js";
31
- import { getTargetManager, tRoot, getEvents, getAnimationManager } from "./App.js";
31
+ import { getTargetManager, getRunScheduler, tRoot, getEvents, getAnimationManager, getManager } from "./App.js";
32
32
 
33
33
  /*
34
34
  * It calculates the locations and dimensions of all objects and triggers the calculation of all targets.
@@ -85,6 +85,7 @@ var LocationManager = /*#__PURE__*/function () {
85
85
  value: function () {
86
86
  var _calculateAll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
87
87
  var budgetMs,
88
+ continueCalculation,
88
89
  calcEpoch,
89
90
  stack,
90
91
  ctx,
@@ -93,18 +94,21 @@ var LocationManager = /*#__PURE__*/function () {
93
94
  while (1) switch (_context.prev = _context.next) {
94
95
  case 0:
95
96
  budgetMs = _args.length > 0 && _args[0] !== undefined ? _args[0] : 8;
97
+ continueCalculation = _args.length > 1 && _args[1] !== undefined ? _args[1] : false;
96
98
  calcEpoch = this.calcEpoch;
97
99
  if (!this.calcBusy) {
98
- _context.next = 5;
100
+ _context.next = 6;
99
101
  break;
100
102
  }
101
103
  this.calcQueued = true;
102
104
  return _context.abrupt("return");
103
- case 5:
105
+ case 6:
104
106
  this.calcBusy = true;
105
- this.hasLocationList.length = 0;
106
- this.hasLocationMap = {};
107
- this.locationListStats = [];
107
+ if (!continueCalculation) {
108
+ this.hasLocationList.length = 0;
109
+ this.hasLocationMap = {};
110
+ this.locationListStats = [];
111
+ }
108
112
  stack = [{
109
113
  container: tRoot(),
110
114
  stage: 'init',
@@ -117,24 +121,24 @@ var LocationManager = /*#__PURE__*/function () {
117
121
  sliceStart: TUtil.now(),
118
122
  calcEpoch: calcEpoch
119
123
  };
120
- _context.next = 13;
124
+ _context.next = 12;
121
125
  return this.processStack(stack, ctx);
122
- case 13:
126
+ case 12:
123
127
  if (!(ctx.calcEpoch !== this.calcEpoch)) {
124
- _context.next = 15;
128
+ _context.next = 14;
125
129
  break;
126
130
  }
127
131
  return _context.abrupt("return");
128
- case 15:
132
+ case 14:
129
133
  this.processAfterStack();
130
134
  this.calcBusy = false;
131
- if (!this.calcQueued) {
132
- _context.next = 20;
133
- break;
135
+ if (this.calcQueued) {
136
+ this.calcQueued = false;
137
+ getRunScheduler().schedule(1, "queuedLocationCalculation");
134
138
  }
135
- this.calcQueued = false;
136
- return _context.abrupt("return", this.calculateAll(budgetMs));
137
- case 20:
139
+
140
+ //console.log(this.locationListStats.length);
141
+ case 17:
138
142
  case "end":
139
143
  return _context.stop();
140
144
  }
@@ -167,15 +171,17 @@ var LocationManager = /*#__PURE__*/function () {
167
171
  container.adjustViewport();
168
172
  container.calcContentWidthHeight();
169
173
  (_container$markLayout = container.markLayoutComplete) === null || _container$markLayout === void 0 || _container$markLayout.call(container, job.layoutEpoch);
174
+ _this.retryPendingTargets(container);
170
175
  (_container$requestPar = container.requestParticleRender) === null || _container$requestPar === void 0 || _container$requestPar.call(container);
176
+ container.visibilityDirty = false;
171
177
  };
172
178
  resetDirtyLayout = function resetDirtyLayout(job) {
173
179
  var children = job.children,
174
180
  index = job.index;
175
181
  var child = children[index];
176
182
  if (child) {
177
- if (child.getDirtyLayout() && child.isComplete() && !child.hasChildren()) {
178
- child.removeLayoutDirty(child, child.dirtyLayout.oids ? Object.keys(child.dirtyLayout.oids) : undefined);
183
+ if (child.getDirtyLayout() && child.isComplete()) {
184
+ child.removeLayoutDirty(child);
179
185
  }
180
186
  }
181
187
  job.stage = 'afterChild';
@@ -239,23 +245,53 @@ var LocationManager = /*#__PURE__*/function () {
239
245
  }
240
246
  }
241
247
  viewport.setCurrentChild(child);
242
- if (!child.getDirtyLayout() && !child.currentStatus && child.activeTargetList.length === 0) {
248
+ if (child.isLightweightChild) {
249
+ _this.calcNextLightweightLocation(child, container, viewport);
250
+ job.index++;
251
+ return;
252
+ }
253
+ if (!child.getDirtyLayout() && !child.visibilityDirty && !container.visibilityDirty && !child.hasEventDirty() && !child.currentStatus && child.activeTargetList.length === 0) {
254
+ var previousAbsX = child.absX;
255
+ var previousAbsY = child.absY;
243
256
  _this.calcNextLocation(child, container, viewport);
257
+ if (child.isIncluded() && child.activateChangedPassiveTargets()) {
258
+ _this.calcQueued = true;
259
+ }
260
+ var positionChanged = child.absX !== previousAbsX || child.absY !== previousAbsY;
261
+ var needsRefresh = child.visibilityDirty || child.hasChildren() && child.isVisible() && positionChanged;
262
+ if (child.getDirtyLayout()) {
263
+ _this.calcQueued = true;
264
+ }
244
265
  job.index++;
266
+ if (needsRefresh && child.hasChildren()) {
267
+ child.visibilityDirty = true;
268
+ stack.push({
269
+ container: child,
270
+ stage: 'init',
271
+ children: [],
272
+ viewport: undefined,
273
+ index: 0
274
+ });
275
+ }
245
276
  return;
246
277
  }
247
278
  if (child.isDomIsland()) {
248
279
  _this.domIslandSet.add(child);
249
280
  }
281
+ var previousLayoutX = child.x;
282
+ var previousLayoutY = child.y;
250
283
  viewport.setLocation();
251
284
  if (viewport.isOverflow()) {
252
285
  viewport.overflow();
253
286
  viewport.setLocation();
254
- child.markLayoutDirty('overflow');
287
+ if (child.x !== previousLayoutX || child.y !== previousLayoutY) {
288
+ child.markLayoutDirty('overflow');
289
+ }
255
290
  }
256
291
  var prevX = Math.floor(child.actualValues.x);
257
292
  var prevY = Math.floor(child.actualValues.y);
258
293
  if (child.isIncluded()) {
294
+ child.activateChangedPassiveTargets();
259
295
  _this.calculateTargets(child);
260
296
  }
261
297
  if (child.isIncluded()) {
@@ -273,13 +309,18 @@ var LocationManager = /*#__PURE__*/function () {
273
309
  if (!TModelUtil.isYDefined(child)) {
274
310
  child.actualValues.y = child.y;
275
311
  }
312
+ _this.catchupNoDomLayoutTargets(child);
276
313
  if (!child.isDomIsland()) {
277
314
  child.calcAbsolutePosition(child.getX(), child.getY());
278
315
  }
279
316
  if (!child.excludeDefaultStyling()) {
280
317
  _this.fixLocation(child, prevX, prevY);
281
318
  }
319
+ var wasVisible = child.isVisible();
282
320
  _this.calculateVisibility(child);
321
+ if (container.visibilityDirty && child.hasChildren() && (wasVisible || child.isVisible())) {
322
+ child.visibilityDirty = true;
323
+ }
283
324
  if (((_child$getDirtyLayout = child.getDirtyLayout()) === null || _child$getDirtyLayout === void 0 ? void 0 : _child$getDirtyLayout.count) > 0) {
284
325
  var _child$getDirtyLayout2, _child$getDirtyLayout3;
285
326
  _this.locationListStats.push("".concat(child.oid, "|").concat((_child$getDirtyLayout2 = child.getDirtyLayout()) === null || _child$getDirtyLayout2 === void 0 ? void 0 : _child$getDirtyLayout2.count, "|").concat((_child$getDirtyLayout3 = child.getDirtyLayout()) === null || _child$getDirtyLayout3 === void 0 ? void 0 : _child$getDirtyLayout3.lastKey));
@@ -421,10 +462,16 @@ var LocationManager = /*#__PURE__*/function () {
421
462
  this.calcNextLightweightLocation(child, container, viewport);
422
463
  return;
423
464
  }
465
+ var previousX = child.x;
466
+ var previousY = child.y;
424
467
  viewport.setLocation();
468
+ var overflowed = false;
425
469
  if (viewport.isOverflow()) {
470
+ overflowed = true;
426
471
  viewport.overflow();
427
472
  viewport.setLocation();
473
+ }
474
+ if (overflowed && (child.x !== previousX || child.y !== previousY)) {
428
475
  child.markLayoutDirty('overflow');
429
476
  }
430
477
  if (child.isIncluded()) {
@@ -441,6 +488,7 @@ var LocationManager = /*#__PURE__*/function () {
441
488
  if (!TModelUtil.isYDefined(child)) {
442
489
  child.actualValues.y = child.y;
443
490
  }
491
+ this.catchupNoDomLayoutTargets(child);
444
492
  if (!child.isDomIsland()) {
445
493
  child.calcAbsolutePosition(child.getX(), child.getY());
446
494
  }
@@ -452,6 +500,11 @@ var LocationManager = /*#__PURE__*/function () {
452
500
  this.addToLocationList(child);
453
501
  }
454
502
  this.calculateVisibility(child);
503
+ var registered = getManager().visibleOidMap[child.oid];
504
+ var shouldBeRegistered = child.isVisible() && child.isIncluded();
505
+ if (shouldBeRegistered ? registered !== child : registered !== undefined) {
506
+ this.addToLocationList(child);
507
+ }
455
508
  if (child.isInFlow()) {
456
509
  if (TUtil.isNumber(child.val('appendNewLine'))) {
457
510
  viewport.appendNewLine();
@@ -469,6 +522,13 @@ var LocationManager = /*#__PURE__*/function () {
469
522
  viewport.overflow();
470
523
  viewport.setLocation();
471
524
  }
525
+ if (!TModelUtil.isXDefined(child)) {
526
+ child.actualValues.x = child.x;
527
+ }
528
+ if (!TModelUtil.isYDefined(child)) {
529
+ child.actualValues.y = child.y;
530
+ }
531
+ this.catchupNoDomLayoutTargets(child);
472
532
  child.calcAbsolutePosition(child.getX(), child.getY());
473
533
  var visible = child.calcVisibility();
474
534
  child.actualValues.isVisible = visible;
@@ -476,11 +536,12 @@ var LocationManager = /*#__PURE__*/function () {
476
536
  container.visibleChildren.push(child);
477
537
  }
478
538
  if (child.isInFlow()) {
479
- if (TUtil.isNumber(child.val('appendNewLine'))) {
539
+ if (TUtil.isNumber(child.val("appendNewLine"))) {
480
540
  viewport.appendNewLine();
481
541
  } else {
482
542
  viewport.nextLocation();
483
543
  }
544
+ container.calcContentWidthHeight();
484
545
  }
485
546
  }
486
547
  }, {
@@ -511,10 +572,13 @@ var LocationManager = /*#__PURE__*/function () {
511
572
  tmodel.actualValues.isVisible = nowVisible;
512
573
  }
513
574
  if (tmodel.isNowVisible || tmodel.isNowInvisible) {
575
+ var _tmodel$onVisibilityC;
514
576
  tmodel.markLayoutDirty('isNowVisible');
515
- }
516
- if (tmodel.isNowInvisible) {
517
577
  this.addToLocationList(tmodel);
578
+ (_tmodel$onVisibilityC = tmodel.onVisibilityChange) === null || _tmodel$onVisibilityC === void 0 || _tmodel$onVisibilityC.call(tmodel, nowVisible);
579
+ }
580
+ if (tmodel.isNowVisible && tmodel.hasChildren()) {
581
+ tmodel.visibilityDirty = true;
518
582
  }
519
583
  ScheduleUtil.pauseResumeSchedule(tmodel);
520
584
  if (tmodel.type !== 'BI' && tmodel.isVisible() && tmodel.isInFlow() && tmodel.getParent()) {
@@ -524,6 +588,9 @@ var LocationManager = /*#__PURE__*/function () {
524
588
  }, {
525
589
  key: "calculateTargets",
526
590
  value: function calculateTargets(tmodel) {
591
+ if (tmodel.hasDomNow) {
592
+ this.retryDomTargets(tmodel);
593
+ }
527
594
  this.checkInternalEvents(tmodel);
528
595
  var guard = 0;
529
596
  while (tmodel.activatedTargets.length && guard++ < 50) {
@@ -543,7 +610,6 @@ var LocationManager = /*#__PURE__*/function () {
543
610
  }
544
611
  }
545
612
  ScheduleUtil.pauseResumeSchedule(tmodel);
546
- tmodel.activateChangedPassiveTargets();
547
613
  getTargetManager().applyTargetValues(tmodel);
548
614
  if (tmodel.updatingTargetList.length > 0) {
549
615
  getTargetManager().setActualValues(tmodel, tmodel.updatingTargetList);
@@ -563,19 +629,58 @@ var LocationManager = /*#__PURE__*/function () {
563
629
  }
564
630
  }
565
631
  if (tmodel.isNowVisible || tmodel.hasDomNow) {
566
- var pending = tmodel.pendingTargets;
567
- if (pending) {
568
- for (var _i = 0, _arr = _toConsumableArray(pending); _i < _arr.length; _i++) {
569
- var _key2 = _arr[_i];
570
- TargetUtil.cleanupTarget(tmodel, _key2);
571
- TargetUtil.shouldActivateNextTarget(tmodel, _key2);
572
- }
573
- }
632
+ this.retryPendingTargets(tmodel);
574
633
  }
575
634
  tmodel.isNowVisible = false;
576
635
  tmodel.hasDomNow = false;
577
636
  tmodel.targetExecutionCount++;
578
637
  }
638
+ }, {
639
+ key: "retryPendingTargets",
640
+ value: function retryPendingTargets(tmodel) {
641
+ var pending = tmodel.pendingTargets;
642
+ if (!(pending !== null && pending !== void 0 && pending.size)) {
643
+ return;
644
+ }
645
+ for (var _i = 0, _arr = _toConsumableArray(pending); _i < _arr.length; _i++) {
646
+ var _tmodel$pendingTarget;
647
+ var key = _arr[_i];
648
+ if (!((_tmodel$pendingTarget = tmodel.pendingTargets) !== null && _tmodel$pendingTarget !== void 0 && _tmodel$pendingTarget.has(key))) {
649
+ continue;
650
+ }
651
+ TargetUtil.cleanupTarget(tmodel, key);
652
+ TargetUtil.shouldActivateNextTarget(tmodel, key);
653
+ }
654
+ }
655
+ }, {
656
+ key: "catchupNoDomLayoutTargets",
657
+ value: function catchupNoDomLayoutTargets(tmodel) {
658
+ var _tmodel$noDomUpdating;
659
+ if (!((_tmodel$noDomUpdating = tmodel.noDomUpdatingTargets) !== null && _tmodel$noDomUpdating !== void 0 && _tmodel$noDomUpdating.size)) {
660
+ return;
661
+ }
662
+ if (tmodel.isLightweightChild) {
663
+ tmodel.catchupNoDomLayoutTargets();
664
+ return;
665
+ }
666
+ var _iterator2 = _createForOfIteratorHelper(tmodel.noDomUpdatingTargets),
667
+ _step2;
668
+ try {
669
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
670
+ var key = _step2.value;
671
+ if (!TargetData.affectsVisibility(key)) {
672
+ continue;
673
+ }
674
+ getTargetManager().catchupTargetByElapsed(tmodel, key, {
675
+ fireEnd: false
676
+ });
677
+ }
678
+ } catch (err) {
679
+ _iterator2.e(err);
680
+ } finally {
681
+ _iterator2.f();
682
+ }
683
+ }
579
684
  }, {
580
685
  key: "checkExternalEvents",
581
686
  value: function checkExternalEvents(tmodel) {
@@ -583,20 +688,20 @@ var LocationManager = /*#__PURE__*/function () {
583
688
  if ((externalEventMap === null || externalEventMap === void 0 ? void 0 : externalEventMap.size) > 0) {
584
689
  var eventTargets = [];
585
690
  var eventMap = TargetData.allEventMap;
586
- var _iterator2 = _createForOfIteratorHelper(externalEventMap),
587
- _step2;
691
+ var _iterator3 = _createForOfIteratorHelper(externalEventMap),
692
+ _step3;
588
693
  try {
589
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
590
- var _step2$value = _slicedToArray(_step2.value, 1),
591
- targetName = _step2$value[0];
694
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
695
+ var _step3$value = _slicedToArray(_step3.value, 1),
696
+ targetName = _step3$value[0];
592
697
  if (eventMap[targetName](tmodel)) {
593
698
  eventTargets.push(tmodel.allTargetMap[targetName]);
594
699
  }
595
700
  }
596
701
  } catch (err) {
597
- _iterator2.e(err);
702
+ _iterator3.e(err);
598
703
  } finally {
599
- _iterator2.f();
704
+ _iterator3.f();
600
705
  }
601
706
  this.runEventTargets(tmodel, eventTargets);
602
707
  }
@@ -608,20 +713,20 @@ var LocationManager = /*#__PURE__*/function () {
608
713
  var eventMap = TargetData.internalEventMap;
609
714
  var internalEventMap = tmodel.internalEventMap;
610
715
  if ((internalEventMap === null || internalEventMap === void 0 ? void 0 : internalEventMap.size) > 0) {
611
- var _iterator3 = _createForOfIteratorHelper(internalEventMap),
612
- _step3;
716
+ var _iterator4 = _createForOfIteratorHelper(internalEventMap),
717
+ _step4;
613
718
  try {
614
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
615
- var _step3$value = _slicedToArray(_step3.value, 1),
616
- targetName = _step3$value[0];
719
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
720
+ var _step4$value = _slicedToArray(_step4.value, 1),
721
+ targetName = _step4$value[0];
617
722
  if (eventMap[targetName](tmodel)) {
618
723
  eventTargets.push(tmodel.allTargetMap[targetName]);
619
724
  }
620
725
  }
621
726
  } catch (err) {
622
- _iterator3.e(err);
727
+ _iterator4.e(err);
623
728
  } finally {
624
- _iterator3.f();
729
+ _iterator4.f();
625
730
  }
626
731
  }
627
732
  this.runEventTargets(tmodel, eventTargets);
@@ -649,6 +754,22 @@ var LocationManager = /*#__PURE__*/function () {
649
754
  }
650
755
  });
651
756
  }
757
+ }, {
758
+ key: "retryDomTargets",
759
+ value: function retryDomTargets(tmodel) {
760
+ var _onDomReady$value;
761
+ var onDomReady = tmodel.targets.onDomReady;
762
+ var value = (_onDomReady$value = onDomReady === null || onDomReady === void 0 ? void 0 : onDomReady.value) !== null && _onDomReady$value !== void 0 ? _onDomReady$value : onDomReady;
763
+ if (!value) {
764
+ return;
765
+ }
766
+ var targets = Array.isArray(value) ? value : [value];
767
+ targets.forEach(function (targetName) {
768
+ if (!targetName.endsWith("$")) {
769
+ TargetUtil.activateSingleTarget(tmodel, targetName);
770
+ }
771
+ });
772
+ }
652
773
  }, {
653
774
  key: "addToLocationList",
654
775
  value: function addToLocationList(tmodel) {