targetj 1.1.0 → 1.1.2

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.
@@ -174,13 +174,14 @@ var TargetUtil = /*#__PURE__*/function () {
174
174
  }
175
175
  var nextTarget = target.activateNextTarget;
176
176
  var isEndTrigger = (_nextTarget$endsWith = nextTarget === null || nextTarget === void 0 ? void 0 : nextTarget.endsWith('$$')) !== null && _nextTarget$endsWith !== void 0 ? _nextTarget$endsWith : false;
177
- var fetchAction = target.fetchAction;
177
+ var fetchAction = TargetUtil.hasFetchAction(tmodel, key);
178
178
  if (isUpdateMode && isEndTrigger) {
179
179
  return;
180
180
  }
181
181
  var nextTargetActivated = false;
182
182
  var canActivate = false;
183
183
  if (nextTarget) {
184
+ var waitingForDom = TargetData.requiresDom(TargetUtil.getTargetName(nextTarget)) && !tmodel.hasDom();
184
185
  if (isEndTrigger) {
185
186
  var lastTriggeredCount = TargetUtil.getTriggeredByCompleteCount(tmodel, nextTarget, key);
186
187
  if (targetValue.completeCount > lastTriggeredCount) {
@@ -193,7 +194,13 @@ var TargetUtil = /*#__PURE__*/function () {
193
194
  }
194
195
  if (!isEndTrigger && sideStep === 0 && (canActivate || isImperative) || isEndTrigger && canActivate) {
195
196
  var prevOk = isEndTrigger ? TargetUtil.arePreviousTargetsComplete(tmodel, nextTarget) : false;
196
- if (fetchAction) {
197
+ if (isEndTrigger) {
198
+ var _tmodel$targetValues, _tmodel$targetValues$2;
199
+ ((_tmodel$targetValues$2 = (_tmodel$targetValues = tmodel.targetValues)[nextTarget]) !== null && _tmodel$targetValues$2 !== void 0 ? _tmodel$targetValues$2 : _tmodel$targetValues[nextTarget] = TargetUtil.emptyValue()).previousTargetsStatus = prevOk;
200
+ }
201
+ if (waitingForDom) {
202
+ TargetUtil.markPendingTargets(tmodel, key);
203
+ } else if (fetchAction) {
197
204
  if (isEndTrigger) {
198
205
  if (prevOk === true) {
199
206
  var activated = TargetUtil.activateTargetOnce(tmodel, nextTarget);
@@ -223,7 +230,7 @@ var TargetUtil = /*#__PURE__*/function () {
223
230
  } else {
224
231
  TargetUtil.markPendingTargets(tmodel, key);
225
232
  }
226
- } else if (!isEndTrigger) {
233
+ } else {
227
234
  if (tmodel.activatedTargets.indexOf(nextTarget) >= 0 && !tmodel.isTargetUpdating(key)) {
228
235
  tmodel.activatedTargets.push(nextTarget);
229
236
  } else {
@@ -254,7 +261,11 @@ var TargetUtil = /*#__PURE__*/function () {
254
261
  var _originalTModel = target.originalTModel,
255
262
  _originalTargetName = target.originalTargetName;
256
263
  if (_originalTModel && _originalTargetName) {
257
- TargetUtil.shouldActivateNextTarget(_originalTModel, _originalTargetName, levelUp + 1, sideStep, isImperative, "complete");
264
+ var _originalTModel$targe, _originalTModel$targe2;
265
+ var completionScope = (_originalTModel$targe = (_originalTModel$targe2 = _originalTModel.targets[_originalTargetName]) === null || _originalTModel$targe2 === void 0 ? void 0 : _originalTModel$targe2.completionScope) !== null && _originalTModel$targe !== void 0 ? _originalTModel$targe : "all";
266
+ if (completionScope !== "none" && TargetUtil.isTModelComplete(tmodel, completionScope)) {
267
+ TargetUtil.shouldActivateNextTarget(_originalTModel, _originalTargetName, levelUp + 1, sideStep, isImperative, "complete");
268
+ }
258
269
  }
259
270
  }
260
271
  }
@@ -311,13 +322,11 @@ var TargetUtil = /*#__PURE__*/function () {
311
322
  target.onComplete.call(tmodel);
312
323
  tmodel.setTargetMethodName(key, "onComplete");
313
324
  }
314
- var fetchAction = target === null || target === void 0 ? void 0 : target.fetchAction;
315
- if (fetchAction && getLoader().isLoadingSuccessful(tmodel, key)) {
325
+ if (TargetUtil.hasFetchAction(tmodel, key) && getLoader().isLoadingSuccessful(tmodel, key)) {
316
326
  var index = tmodel.fetchActionTargetList.indexOf(key);
317
327
  if (index >= 0) {
318
328
  tmodel.fetchActionTargetList.splice(index, 1);
319
329
  }
320
- target.fetchAction = false;
321
330
  }
322
331
  TargetUtil.bubbleInvokerCompletion(tmodel, key);
323
332
  return true;
@@ -391,35 +400,35 @@ var TargetUtil = /*#__PURE__*/function () {
391
400
  }, {
392
401
  key: "getTriggeredByCompleteCount",
393
402
  value: function getTriggeredByCompleteCount(tmodel, nextTarget, key) {
394
- var _tmodel$targetValues$2, _tmodel$targetValues$3;
395
- return (_tmodel$targetValues$2 = (_tmodel$targetValues$3 = tmodel.targetValues[nextTarget]) === null || _tmodel$targetValues$3 === void 0 || (_tmodel$targetValues$3 = _tmodel$targetValues$3.triggeredByCompleteCountMap) === null || _tmodel$targetValues$3 === void 0 ? void 0 : _tmodel$targetValues$3.get(key)) !== null && _tmodel$targetValues$2 !== void 0 ? _tmodel$targetValues$2 : 0;
403
+ var _tmodel$targetValues$3, _tmodel$targetValues$4;
404
+ return (_tmodel$targetValues$3 = (_tmodel$targetValues$4 = tmodel.targetValues[nextTarget]) === null || _tmodel$targetValues$4 === void 0 || (_tmodel$targetValues$4 = _tmodel$targetValues$4.triggeredByCompleteCountMap) === null || _tmodel$targetValues$4 === void 0 ? void 0 : _tmodel$targetValues$4.get(key)) !== null && _tmodel$targetValues$3 !== void 0 ? _tmodel$targetValues$3 : 0;
396
405
  }
397
406
  }, {
398
407
  key: "snapshotTriggeredByCompleteCounts",
399
408
  value: function snapshotTriggeredByCompleteCounts(tmodel, nextTarget) {
400
- var _tmodel$targetValues;
401
- var nextTargetValue = (_tmodel$targetValues = tmodel.targetValues)[nextTarget] || (_tmodel$targetValues[nextTarget] = TargetUtil.emptyValue());
409
+ var _tmodel$targetValues2;
410
+ var nextTargetValue = (_tmodel$targetValues2 = tmodel.targetValues)[nextTarget] || (_tmodel$targetValues2[nextTarget] = TargetUtil.emptyValue());
402
411
  var map = nextTargetValue.triggeredByCompleteCountMap || (nextTargetValue.triggeredByCompleteCountMap = new Map());
403
412
  var nextIndex = tmodel.functionTargetNames.indexOf(nextTarget);
404
413
  if (nextIndex < 0) {
405
414
  return;
406
415
  }
407
416
  for (var i = 0; i < nextIndex; i++) {
408
- var _tmodel$targetValues$4, _tmodel$targetValues$5;
417
+ var _tmodel$targetValues$5, _tmodel$targetValues$6;
409
418
  var previousKey = tmodel.functionTargetNames[i];
410
419
  var previousTarget = tmodel.targets[previousKey];
411
420
  if ((previousTarget === null || previousTarget === void 0 ? void 0 : previousTarget.activateNextTarget) !== nextTarget) {
412
421
  continue;
413
422
  }
414
- var completeCount = (_tmodel$targetValues$4 = (_tmodel$targetValues$5 = tmodel.targetValues[previousKey]) === null || _tmodel$targetValues$5 === void 0 ? void 0 : _tmodel$targetValues$5.completeCount) !== null && _tmodel$targetValues$4 !== void 0 ? _tmodel$targetValues$4 : 0;
423
+ var completeCount = (_tmodel$targetValues$5 = (_tmodel$targetValues$6 = tmodel.targetValues[previousKey]) === null || _tmodel$targetValues$6 === void 0 ? void 0 : _tmodel$targetValues$6.completeCount) !== null && _tmodel$targetValues$5 !== void 0 ? _tmodel$targetValues$5 : 0;
415
424
  map.set(previousKey, completeCount);
416
425
  }
417
426
  }
418
427
  }, {
419
428
  key: "activateTargetOnce",
420
429
  value: function activateTargetOnce(tmodel, nextTarget) {
421
- var _tmodel$targetValues2, _nextTargetValue$acti;
422
- var nextTargetValue = (_tmodel$targetValues2 = tmodel.targetValues)[nextTarget] || (_tmodel$targetValues2[nextTarget] = TargetUtil.emptyValue());
430
+ var _tmodel$targetValues3, _nextTargetValue$acti;
431
+ var nextTargetValue = (_tmodel$targetValues3 = tmodel.targetValues)[nextTarget] || (_tmodel$targetValues3[nextTarget] = TargetUtil.emptyValue());
423
432
  var last = (_nextTargetValue$acti = nextTargetValue.activationTime) !== null && _nextTargetValue$acti !== void 0 ? _nextTargetValue$acti : 0;
424
433
  if (last > 0 && last >= tmodel.getLastUpdate(nextTarget)) {
425
434
  return false;
@@ -436,33 +445,42 @@ var TargetUtil = /*#__PURE__*/function () {
436
445
  }, {
437
446
  key: "isTModelComplete",
438
447
  value: function isTModelComplete(tmodel) {
439
- var _state$updatingTarget2, _state$activeTargetLi2, _state$activatedTarge2, _state$lastChildrenUp3, _state$lastChildrenUp4;
448
+ var _tmodel$particleRunti, _state$updatingTarget2, _state$activeTargetLi2, _state$activatedTarge2, _state$lastChildrenUp3, _state$lastChildrenUp4;
440
449
  var completionScope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "all";
450
+ if (completionScope === "visible" && TargetUtil.shouldIgnoreChildForCompletion(tmodel, "visible")) {
451
+ return true;
452
+ }
453
+ if ((_tmodel$particleRunti = tmodel.particleRuntime) !== null && _tmodel$particleRunti !== void 0 && _tmodel$particleRunti.hasPendingAny(completionScope)) {
454
+ return false;
455
+ }
456
+ var waitingForDom = !tmodel.isLightweightChild && getManager().shouldHaveDom(tmodel) && !tmodel.hasDom();
441
457
  var state = tmodel.state();
458
+ var pendingStyles = !tmodel.isLightweightChild && TargetUtil.hasPendingStyles(tmodel);
459
+ var needsReattach = !tmodel.isLightweightChild && getManager().needsReattach(tmodel);
442
460
  if (completionScope === "visible") {
443
461
  var _state$updatingTarget, _state$activeTargetLi, _state$activatedTarge, _state$lastChildrenUp, _state$lastChildrenUp2;
444
- if (TargetUtil.shouldIgnoreChildForCompletion(tmodel, "visible")) {
445
- return true;
446
- }
447
- return !((_state$updatingTarget = state.updatingTargetList) !== null && _state$updatingTarget !== void 0 && _state$updatingTarget.length) && !((_state$activeTargetLi = state.activeTargetList) !== null && _state$activeTargetLi !== void 0 && _state$activeTargetLi.length) && !((_state$activatedTarge = state.activatedTargets) !== null && _state$activatedTarge !== void 0 && _state$activatedTarge.length) && !tmodel.hasAnimatingTargets() && TargetUtil.isFetchingComplete(tmodel) && TargetUtil.getUpdatingChildren(tmodel, undefined, "visible").size === 0 && TargetUtil.getActiveChildren(tmodel, "visible").size === 0 && !((_state$lastChildrenUp = state.lastChildrenUpdate) !== null && _state$lastChildrenUp !== void 0 && (_state$lastChildrenUp = _state$lastChildrenUp.deletions) !== null && _state$lastChildrenUp !== void 0 && _state$lastChildrenUp.length) && !((_state$lastChildrenUp2 = state.lastChildrenUpdate) !== null && _state$lastChildrenUp2 !== void 0 && (_state$lastChildrenUp2 = _state$lastChildrenUp2.additions) !== null && _state$lastChildrenUp2 !== void 0 && _state$lastChildrenUp2.length) && !tmodel.noDomUpdatingTargets && !tmodel.pendingTargets && !getManager().needsReattach(tmodel);
462
+ return !waitingForDom && !((_state$updatingTarget = state.updatingTargetList) !== null && _state$updatingTarget !== void 0 && _state$updatingTarget.length) && !((_state$activeTargetLi = state.activeTargetList) !== null && _state$activeTargetLi !== void 0 && _state$activeTargetLi.length) && !((_state$activatedTarge = state.activatedTargets) !== null && _state$activatedTarge !== void 0 && _state$activatedTarge.length) && !tmodel.hasAnimatingTargets() && TargetUtil.isFetchingComplete(tmodel) && TargetUtil.getUpdatingChildren(tmodel, undefined, "visible").size === 0 && TargetUtil.getActiveChildren(tmodel, "visible").size === 0 && !((_state$lastChildrenUp = state.lastChildrenUpdate) !== null && _state$lastChildrenUp !== void 0 && (_state$lastChildrenUp = _state$lastChildrenUp.deletions) !== null && _state$lastChildrenUp !== void 0 && _state$lastChildrenUp.length) && !((_state$lastChildrenUp2 = state.lastChildrenUpdate) !== null && _state$lastChildrenUp2 !== void 0 && (_state$lastChildrenUp2 = _state$lastChildrenUp2.additions) !== null && _state$lastChildrenUp2 !== void 0 && _state$lastChildrenUp2.length) && !tmodel.noDomUpdatingTargets && !tmodel.pendingTargets && !pendingStyles && !needsReattach;
448
463
  }
449
- return !((_state$updatingTarget2 = state.updatingTargetList) !== null && _state$updatingTarget2 !== void 0 && _state$updatingTarget2.length) && !((_state$activeTargetLi2 = state.activeTargetList) !== null && _state$activeTargetLi2 !== void 0 && _state$activeTargetLi2.length) && !((_state$activatedTarge2 = state.activatedTargets) !== null && _state$activatedTarge2 !== void 0 && _state$activatedTarge2.length) && !tmodel.hasAnimatingTargets() && TargetUtil.isFetchingComplete(tmodel) && !tmodel.hasAnimatingChildren() && !tmodel.hasUpdatingChildren() && !tmodel.hasActiveChildren() && !((_state$lastChildrenUp3 = state.lastChildrenUpdate) !== null && _state$lastChildrenUp3 !== void 0 && (_state$lastChildrenUp3 = _state$lastChildrenUp3.deletions) !== null && _state$lastChildrenUp3 !== void 0 && _state$lastChildrenUp3.length) && !((_state$lastChildrenUp4 = state.lastChildrenUpdate) !== null && _state$lastChildrenUp4 !== void 0 && (_state$lastChildrenUp4 = _state$lastChildrenUp4.additions) !== null && _state$lastChildrenUp4 !== void 0 && _state$lastChildrenUp4.length) && !tmodel.noDomUpdatingTargets && !tmodel.pendingTargets && !getManager().needsReattach(tmodel);
464
+ return !waitingForDom && !((_state$updatingTarget2 = state.updatingTargetList) !== null && _state$updatingTarget2 !== void 0 && _state$updatingTarget2.length) && !((_state$activeTargetLi2 = state.activeTargetList) !== null && _state$activeTargetLi2 !== void 0 && _state$activeTargetLi2.length) && !((_state$activatedTarge2 = state.activatedTargets) !== null && _state$activatedTarge2 !== void 0 && _state$activatedTarge2.length) && !tmodel.hasAnimatingTargets() && TargetUtil.isFetchingComplete(tmodel) && !tmodel.hasAnimatingChildren() && !tmodel.hasUpdatingChildren() && !tmodel.hasActiveChildren() && !((_state$lastChildrenUp3 = state.lastChildrenUpdate) !== null && _state$lastChildrenUp3 !== void 0 && (_state$lastChildrenUp3 = _state$lastChildrenUp3.deletions) !== null && _state$lastChildrenUp3 !== void 0 && _state$lastChildrenUp3.length) && !((_state$lastChildrenUp4 = state.lastChildrenUpdate) !== null && _state$lastChildrenUp4 !== void 0 && (_state$lastChildrenUp4 = _state$lastChildrenUp4.additions) !== null && _state$lastChildrenUp4 !== void 0 && _state$lastChildrenUp4.length) && !tmodel.noDomUpdatingTargets && !tmodel.pendingTargets && !pendingStyles && !needsReattach;
450
465
  }
451
466
  }, {
452
467
  key: "getCompletionBlockers",
453
468
  value: function getCompletionBlockers(tmodel) {
454
- var _state$lastChildrenUp7, _state$lastChildrenUp8;
469
+ var _state$lastChildrenUp5, _state$lastChildrenUp6;
455
470
  var completionScope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "all";
471
+ var visible = completionScope === "visible";
472
+ if (visible && TargetUtil.shouldIgnoreChildForCompletion(tmodel, "visible")) {
473
+ return [];
474
+ }
456
475
  var state = tmodel.state();
457
476
  var blockers = [];
458
477
  var add = function add(name, value) {
459
- if (!value) {
460
- return;
478
+ if (value && (!Array.isArray(value) || value.length > 0)) {
479
+ blockers.push({
480
+ name: name,
481
+ value: value
482
+ });
461
483
  }
462
- blockers.push({
463
- name: name,
464
- value: value
465
- });
466
484
  };
467
485
  var list = function list(value) {
468
486
  if (!value) {
@@ -474,56 +492,38 @@ var TargetUtil = /*#__PURE__*/function () {
474
492
  if (value instanceof Map) {
475
493
  return _toConsumableArray(value.keys());
476
494
  }
477
- if (Array.isArray(value)) {
478
- return value;
479
- }
480
- return [value];
495
+ return Array.isArray(value) ? value : [value];
481
496
  };
482
- if (completionScope === "visible") {
483
- var _state$lastChildrenUp5, _state$lastChildrenUp6;
484
- if (TargetUtil.shouldIgnoreChildForCompletion(tmodel, "visible")) {
485
- return [];
486
- }
487
- var updatingChildren = TargetUtil.getUpdatingChildren(tmodel, undefined, "visible");
488
- var activeChildren = TargetUtil.getActiveChildren(tmodel, "visible");
489
- add("updatingTargetList", list(state.updatingTargetList));
490
- add("activeTargetList", list(state.activeTargetList));
491
- add("activatedTargets", list(state.activatedTargets));
492
- add("animatingTargets", tmodel.hasAnimatingTargets() ? list(tmodel.animatingMap) : []);
493
- add("fetching", !TargetUtil.isFetchingComplete(tmodel) ? true : false);
494
- add("updatingChildren", _toConsumableArray(updatingChildren.keys()));
495
- add("activeChildren", _toConsumableArray(activeChildren.keys()));
496
- add("deletedChildren", list((_state$lastChildrenUp5 = state.lastChildrenUpdate) === null || _state$lastChildrenUp5 === void 0 ? void 0 : _state$lastChildrenUp5.deletions));
497
- add("addedChildren", list((_state$lastChildrenUp6 = state.lastChildrenUpdate) === null || _state$lastChildrenUp6 === void 0 ? void 0 : _state$lastChildrenUp6.additions));
498
- add("noDomUpdatingTargets", list(tmodel.noDomUpdatingTargets));
499
- add("pendingTargets", list(tmodel.pendingTargets));
500
- add("needsReattach", getManager().needsReattach(tmodel) ? true : false);
501
- return blockers.filter(function (blocker) {
502
- if (Array.isArray(blocker.value)) {
503
- return blocker.value.length > 0;
504
- }
505
- return !!blocker.value;
506
- });
507
- }
497
+ add("waitingForDom", !tmodel.isLightweightChild && getManager().shouldHaveDom(tmodel) && !tmodel.hasDom());
508
498
  add("updatingTargetList", list(state.updatingTargetList));
509
499
  add("activeTargetList", list(state.activeTargetList));
510
500
  add("activatedTargets", list(state.activatedTargets));
511
501
  add("animatingTargets", tmodel.hasAnimatingTargets() ? list(tmodel.animatingMap) : []);
512
- add("fetching", !TargetUtil.isFetchingComplete(tmodel) ? true : false);
513
- add("animatingChildren", tmodel.hasAnimatingChildren() ? true : false);
514
- add("updatingChildren", tmodel.hasUpdatingChildren() ? list(tmodel.updatingChildrenMap) : []);
515
- add("activeChildren", tmodel.hasActiveChildren() ? list(tmodel.activeChildrenMap) : []);
516
- add("deletedChildren", list((_state$lastChildrenUp7 = state.lastChildrenUpdate) === null || _state$lastChildrenUp7 === void 0 ? void 0 : _state$lastChildrenUp7.deletions));
517
- add("addedChildren", list((_state$lastChildrenUp8 = state.lastChildrenUpdate) === null || _state$lastChildrenUp8 === void 0 ? void 0 : _state$lastChildrenUp8.additions));
502
+ add("fetching", !TargetUtil.isFetchingComplete(tmodel));
503
+ if (visible) {
504
+ add("updatingChildren", _toConsumableArray(TargetUtil.getUpdatingChildren(tmodel, undefined, "visible").keys()));
505
+ add("activeChildren", _toConsumableArray(TargetUtil.getActiveChildren(tmodel, "visible").keys()));
506
+ } else {
507
+ add("animatingChildren", tmodel.hasAnimatingChildren());
508
+ add("updatingChildren", tmodel.hasUpdatingChildren() ? list(tmodel.updatingChildrenMap) : []);
509
+ add("activeChildren", tmodel.hasActiveChildren() ? list(tmodel.activeChildrenMap) : []);
510
+ }
511
+ add("deletedChildren", list((_state$lastChildrenUp5 = state.lastChildrenUpdate) === null || _state$lastChildrenUp5 === void 0 ? void 0 : _state$lastChildrenUp5.deletions));
512
+ add("addedChildren", list((_state$lastChildrenUp6 = state.lastChildrenUpdate) === null || _state$lastChildrenUp6 === void 0 ? void 0 : _state$lastChildrenUp6.additions));
518
513
  add("noDomUpdatingTargets", list(tmodel.noDomUpdatingTargets));
519
514
  add("pendingTargets", list(tmodel.pendingTargets));
520
- add("needsReattach", getManager().needsReattach(tmodel) ? true : false);
521
- return blockers.filter(function (blocker) {
522
- if (Array.isArray(blocker.value)) {
523
- return blocker.value.length > 0;
524
- }
525
- return !!blocker.value;
526
- });
515
+ if (tmodel.hasDom()) {
516
+ add("styleTargetMap", list(tmodel.styleTargetMap));
517
+ add("asyncStyleTargetMap", list(tmodel.asyncStyleTargetMap));
518
+ }
519
+ add("needsReattach", getManager().needsReattach(tmodel));
520
+ return blockers;
521
+ }
522
+ }, {
523
+ key: "hasPendingStyles",
524
+ value: function hasPendingStyles(tmodel) {
525
+ var _tmodel$styleTargetMa, _tmodel$asyncStyleTar;
526
+ return tmodel.hasDom() && (((_tmodel$styleTargetMa = tmodel.styleTargetMap) === null || _tmodel$styleTargetMa === void 0 ? void 0 : _tmodel$styleTargetMa.size) > 0 || ((_tmodel$asyncStyleTar = tmodel.asyncStyleTargetMap) === null || _tmodel$asyncStyleTar === void 0 ? void 0 : _tmodel$asyncStyleTar.size) > 0);
527
527
  }
528
528
  }, {
529
529
  key: "isFetchingComplete",
@@ -567,6 +567,9 @@ var TargetUtil = /*#__PURE__*/function () {
567
567
  var keyIndex = tmodel.functionTargetNames.findIndex(function (name) {
568
568
  return key === name;
569
569
  });
570
+ if (TargetUtil.hasPendingStyles(tmodel)) {
571
+ return "pending styles";
572
+ }
570
573
  for (var i = keyIndex - 1; i >= 0; i--) {
571
574
  var targetName = tmodel.functionTargetNames[i];
572
575
  if (tmodel.isTargetImperative(targetName)) {
@@ -582,9 +585,12 @@ var TargetUtil = /*#__PURE__*/function () {
582
585
  return tmodel.oid + "." + targetName + ": " + tmodel.getUpdatingImperativeTargets(targetName);
583
586
  }
584
587
  if (tmodel.isTargetTreeComplete(targetName) !== true) {
585
- //const activeChildrenList = [ ...TargetUtil.getActiveChildren(tmodel, tmodel.targets[targetName].completionScope).values() ];
586
- //return tmodel.oid + "." + targetName + " ==> " + tmodel.getTargetStatus(targetName) + ", " + TargetUtil.isTargetTreeComplete(tmodel, targetName) + ":: " + activeChildrenList.map(t => t.oid + ':' + t.hasAnyUpdates()) + ", " + [ ...TargetUtil.getUpdatingChildren(tmodel, targetName, tmodel.targets[targetName].completionScope).keys() ];
587
- return false;
588
+ var _tmodel$targets$targe;
589
+ var completionScope = (_tmodel$targets$targe = tmodel.targets[targetName].completionScope) !== null && _tmodel$targets$targe !== void 0 ? _tmodel$targets$targe : "all";
590
+ var reason = TargetUtil.isTargetTreeComplete(tmodel, targetName);
591
+ var activeChildren = _toConsumableArray(TargetUtil.getActiveChildren(tmodel, completionScope).keys());
592
+ var updatingChildren = _toConsumableArray(TargetUtil.getUpdatingChildren(tmodel, targetName, completionScope).keys());
593
+ return "".concat(tmodel.oid, ".").concat(targetName, ": ").concat(reason, "; active=[").concat(activeChildren.join(", "), "]; updating=[").concat(updatingChildren.join(", "), "]");
588
594
  }
589
595
  }
590
596
  return true;
@@ -593,14 +599,19 @@ var TargetUtil = /*#__PURE__*/function () {
593
599
  key: "isTargetTreeComplete",
594
600
  value: function isTargetTreeComplete(tmodel, key, completionScopeOverride) {
595
601
  var target = tmodel.targets[key];
602
+ var targetValue = tmodel.targetValues[key];
603
+ var childAction = targetValue === null || targetValue === void 0 ? void 0 : targetValue.childAction;
596
604
  if (target) {
597
- var _target$childAction, _target$childAction2, _target$childAction3, _tmodel$particleRunti;
605
+ var _tmodel$particleRunti2, _tmodel$particleRunti3;
598
606
  var completionScope = completionScopeOverride !== null && completionScopeOverride !== void 0 ? completionScopeOverride : target.completionScope;
607
+ if ((_tmodel$particleRunti2 = tmodel.particleRuntime) !== null && _tmodel$particleRunti2 !== void 0 && _tmodel$particleRunti2.hasPending(key, completionScope !== null && completionScope !== void 0 ? completionScope : "all")) {
608
+ return "pending GPU children";
609
+ }
599
610
  var targetType = _typeof(target.value);
600
611
  if (TargetData.controlTargetMap[key]) {
601
612
  return true;
602
613
  }
603
- if (!target.fetchAction && (targetType === 'string' || targetType === 'number' || targetType === 'boolean')) {
614
+ if (!TargetUtil.hasFetchAction(tmodel, key) && (targetType === 'string' || targetType === 'number' || targetType === 'boolean')) {
604
615
  return true;
605
616
  }
606
617
  if (getManager().needsReattach(tmodel)) {
@@ -612,19 +623,20 @@ var TargetUtil = /*#__PURE__*/function () {
612
623
  if (!tmodel.isTargetComplete(key) && !tmodel.isTargetDone(key)) {
613
624
  return 'not done';
614
625
  }
615
- if (((_target$childAction = target.childAction) === null || _target$childAction === void 0 ? void 0 : _target$childAction.length) > 0 && TargetUtil.getUpdatingChildren(tmodel, key, completionScope).size > 0) {
616
- return 'updating children';
626
+ var children;
627
+ if ((childAction === null || childAction === void 0 ? void 0 : childAction.length) > 0 && (children = TargetUtil.getUpdatingChildren(tmodel, key, completionScope)).size > 0) {
628
+ return "updating children: " + _toConsumableArray(children.keys()).join(", ");
617
629
  }
618
- if (((_target$childAction2 = target.childAction) === null || _target$childAction2 === void 0 ? void 0 : _target$childAction2.length) > 0 && TargetUtil.getActiveChildren(tmodel, completionScope).size > 0) {
619
- return 'active children';
630
+ if ((childAction === null || childAction === void 0 ? void 0 : childAction.length) > 0 && (children = TargetUtil.getActiveChildren(tmodel, completionScope)).size > 0) {
631
+ return "active children: " + _toConsumableArray(children.keys()).join(", ");
620
632
  }
621
- if (((_target$childAction3 = target.childAction) === null || _target$childAction3 === void 0 ? void 0 : _target$childAction3.length) > 0 && TargetUtil.areTargetChildrenComplete(target.childAction, completionScope) !== true) {
622
- return 'incomplete children';
633
+ if ((childAction === null || childAction === void 0 ? void 0 : childAction.length) > 0 && (children = TargetUtil.areTargetChildrenComplete(childAction, completionScope)) !== true) {
634
+ return "incomplete children: " + children;
623
635
  }
624
- if (target.fetchAction && !getLoader().isLoadingSuccessful(tmodel, key)) {
636
+ if (TargetUtil.hasFetchAction(tmodel, key) && !getLoader().isLoadingSuccessful(tmodel, key)) {
625
637
  return 'incomplete loading';
626
638
  }
627
- if ((_tmodel$particleRunti = tmodel.particleRuntime) !== null && _tmodel$particleRunti !== void 0 && _tmodel$particleRunti.hasPending(key, completionScope)) {
639
+ if ((_tmodel$particleRunti3 = tmodel.particleRuntime) !== null && _tmodel$particleRunti3 !== void 0 && _tmodel$particleRunti3.hasPending(key, completionScope)) {
628
640
  return "pending GPU children";
629
641
  }
630
642
  }
@@ -697,9 +709,9 @@ var TargetUtil = /*#__PURE__*/function () {
697
709
  if (imperativeOriginalTarget === originalTargetName) {
698
710
  childrenMap.set(child.oid, child);
699
711
  } else if (imperativeOriginalTarget) {
700
- var _child$targetValues$t3, _originalTModel$targe;
712
+ var _child$targetValues$t3, _originalTModel$targe3;
701
713
  var originalTModel = (_child$targetValues$t3 = child.targetValues[target]) === null || _child$targetValues$t3 === void 0 ? void 0 : _child$targetValues$t3.originalTModel;
702
- if (((_originalTModel$targe = originalTModel.targets[imperativeOriginalTarget]) === null || _originalTModel$targe === void 0 ? void 0 : _originalTModel$targe.originalTargetName) === originalTargetName) {
714
+ if (((_originalTModel$targe3 = originalTModel.targets[imperativeOriginalTarget]) === null || _originalTModel$targe3 === void 0 ? void 0 : _originalTModel$targe3.originalTargetName) === originalTargetName) {
703
715
  childrenMap.set(child.oid, child);
704
716
  }
705
717
  }
@@ -767,6 +779,10 @@ var TargetUtil = /*#__PURE__*/function () {
767
779
  }, {
768
780
  key: "shouldIgnoreChildForCompletion",
769
781
  value: function shouldIgnoreChildForCompletion(child, completionScope) {
782
+ if (child && typeof child.exists !== "function") {
783
+ console.warn("Invalid child reference", JSON.stringify(child));
784
+ return true;
785
+ }
770
786
  if (!child || !child.exists()) {
771
787
  return true;
772
788
  }
@@ -796,44 +812,44 @@ var TargetUtil = /*#__PURE__*/function () {
796
812
  }
797
813
  }
798
814
  }, {
799
- key: "markChildAction",
800
- value: function markChildAction(parentTModel, parentTargetName, child) {
801
- var target = parentTModel.targets[parentTargetName];
802
- if (_typeof(target) === 'object') {
803
- if (!target['childAction']) {
804
- target['childAction'] = [child];
805
- } else if (!target['childAction'].includes(child)) {
806
- target['childAction'].push(child);
807
- }
815
+ key: "markTargetChildAction",
816
+ value: function markTargetChildAction(tmodel, key, child, action) {
817
+ var _tmodel$targetValues4, _tmodel$targetValues5, _targetValue$action;
818
+ if (!child || !(tmodel !== null && tmodel !== void 0 && tmodel.targets[key]) || _typeof(tmodel.targets[key]) !== "object") {
819
+ return;
820
+ }
821
+ var targetValue = (_tmodel$targetValues5 = (_tmodel$targetValues4 = tmodel.targetValues)[key]) !== null && _tmodel$targetValues5 !== void 0 ? _tmodel$targetValues5 : _tmodel$targetValues4[key] = TargetUtil.emptyValue();
822
+ var children = (_targetValue$action = targetValue[action]) !== null && _targetValue$action !== void 0 ? _targetValue$action : targetValue[action] = [];
823
+ if (!children.includes(child)) {
824
+ children.push(child);
808
825
  }
809
826
  }
827
+ }, {
828
+ key: "markChildAction",
829
+ value: function markChildAction(tmodel, key, child) {
830
+ TargetUtil.markTargetChildAction(tmodel, key, child, "childAction");
831
+ }
810
832
  }, {
811
833
  key: "markAddChild",
812
- value: function markAddChild(parentTModel, parentTargetName, child) {
813
- var target = parentTModel.targets[parentTargetName];
814
- if (_typeof(target) === 'object') {
815
- if (!target['addChildAction']) {
816
- target['addChildAction'] = [child];
817
- } else if (!target['addChildAction'].includes(child)) {
818
- target['addChildAction'].push(child);
819
- }
820
- }
834
+ value: function markAddChild(tmodel, key, child) {
835
+ TargetUtil.markTargetChildAction(tmodel, key, child, "addChildAction");
821
836
  }
822
837
  }, {
823
838
  key: "markFetchAction",
824
839
  value: function markFetchAction(tmodel) {
825
- if (!tmodel) {
840
+ var key = TargetUtil.currentTargetName;
841
+ if (!(tmodel !== null && tmodel !== void 0 && tmodel.targets[key])) {
826
842
  return;
827
843
  }
828
- var currentTargetName = TargetUtil.currentTargetName;
829
- var target = tmodel.targets[currentTargetName];
830
- if (_typeof(target) === 'object') {
831
- target['fetchAction'] = true;
832
- if (!tmodel.fetchActionTargetList.includes(currentTargetName)) {
833
- tmodel.fetchActionTargetList.push(currentTargetName);
834
- }
844
+ if (!tmodel.fetchActionTargetList.includes(key)) {
845
+ tmodel.fetchActionTargetList.push(key);
835
846
  }
836
847
  }
848
+ }, {
849
+ key: "hasFetchAction",
850
+ value: function hasFetchAction(tmodel, key) {
851
+ return tmodel.fetchActionTargetList.includes(key);
852
+ }
837
853
  }, {
838
854
  key: "wrapTarget",
839
855
  value: function wrapTarget(tmodel, target, key) {
@@ -867,9 +883,9 @@ var TargetUtil = /*#__PURE__*/function () {
867
883
  value: function getOriginalNames(tmodel, key) {
868
884
  var originalTModel, originalTargetName;
869
885
  if (tmodel.isTargetImperative(key)) {
870
- var _tmodel$targetValues$6, _tmodel$targetValues$7;
871
- originalTModel = (_tmodel$targetValues$6 = tmodel.targetValues[key]) === null || _tmodel$targetValues$6 === void 0 ? void 0 : _tmodel$targetValues$6.originalTModel;
872
- originalTargetName = (_tmodel$targetValues$7 = tmodel.targetValues[key]) === null || _tmodel$targetValues$7 === void 0 ? void 0 : _tmodel$targetValues$7.originalTargetName;
886
+ var _tmodel$targetValues$7, _tmodel$targetValues$8;
887
+ originalTModel = (_tmodel$targetValues$7 = tmodel.targetValues[key]) === null || _tmodel$targetValues$7 === void 0 ? void 0 : _tmodel$targetValues$7.originalTModel;
888
+ originalTargetName = (_tmodel$targetValues$8 = tmodel.targetValues[key]) === null || _tmodel$targetValues$8 === void 0 ? void 0 : _tmodel$targetValues$8.originalTargetName;
873
889
  } else {
874
890
  var _tmodel$targets$key4, _tmodel$targets$key5;
875
891
  originalTModel = (_tmodel$targets$key4 = tmodel.targets[key]) === null || _tmodel$targets$key4 === void 0 ? void 0 : _tmodel$targets$key4.originalTModel;
@@ -961,14 +977,15 @@ var TargetUtil = /*#__PURE__*/function () {
961
977
  }, {
962
978
  key: "resetTargetChildActions",
963
979
  value: function resetTargetChildActions(tmodel, key) {
980
+ var _targetValue$childAct, _targetValue$addChild;
964
981
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
965
982
  var visited = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new Set();
966
- var target = tmodel.targets[key];
967
- if (!target) {
983
+ var targetValue = tmodel.targetValues[key];
984
+ if (!targetValue) {
968
985
  return;
969
986
  }
970
- var childActions = target.childAction ? _toConsumableArray(target.childAction) : [];
971
- var addChildActions = target.addChildAction ? _toConsumableArray(target.addChildAction) : [];
987
+ var childActions = _toConsumableArray((_targetValue$childAct = targetValue.childAction) !== null && _targetValue$childAct !== void 0 ? _targetValue$childAct : []);
988
+ var addChildActions = _toConsumableArray((_targetValue$addChild = targetValue.addChildAction) !== null && _targetValue$addChild !== void 0 ? _targetValue$addChild : []);
972
989
  childActions.forEach(function (child) {
973
990
  if (child) {
974
991
  TargetUtil.resetTargetChildState(child, options, visited);
@@ -980,11 +997,11 @@ var TargetUtil = /*#__PURE__*/function () {
980
997
  }
981
998
  });
982
999
  if (options.clearChildActions) {
983
- if (Array.isArray(target.childAction)) {
984
- target.childAction.length = 0;
1000
+ if (Array.isArray(targetValue.childAction)) {
1001
+ targetValue.childAction = [];
985
1002
  }
986
- if (Array.isArray(target.addChildAction)) {
987
- target.addChildAction.length = 0;
1003
+ if (Array.isArray(targetValue.addChildAction)) {
1004
+ targetValue.addChildAction = [];
988
1005
  }
989
1006
  }
990
1007
  }
@@ -1002,8 +1019,8 @@ var TargetUtil = /*#__PURE__*/function () {
1002
1019
  }
1003
1020
  }
1004
1021
  }, {
1005
- key: "resetSingleTargetState",
1006
- value: function resetSingleTargetState(tmodel, key) {
1022
+ key: "resetTargetStateOnly",
1023
+ value: function resetTargetStateOnly(tmodel, key) {
1007
1024
  var _tmodel$targets$key6;
1008
1025
  var targetValue = tmodel.targetValues[key];
1009
1026
  var nextTarget = (_tmodel$targets$key6 = tmodel.targets[key]) === null || _tmodel$targets$key6 === void 0 ? void 0 : _tmodel$targets$key6.activateNextTarget;
@@ -1016,15 +1033,38 @@ var TargetUtil = /*#__PURE__*/function () {
1016
1033
  targetValue.resetFlag = true;
1017
1034
  targetValue.nextTargetUpdateCount = 0;
1018
1035
  targetValue.visibleCompleteSignature = undefined;
1019
- targetValue.status = '';
1036
+ targetValue.status = "";
1020
1037
  }
1021
- tmodel.cancelAnimation();
1022
- tmodel.activatedTargets.length = 0;
1023
1038
  tmodel.removeFromActiveTargets(key);
1024
1039
  tmodel.removeFromAnimatingMap(key);
1025
1040
  tmodel.removeFromUpdatingTargets(key);
1026
1041
  TargetUtil.clearPendingTarget(tmodel, key);
1027
1042
  }
1043
+ }, {
1044
+ key: "resetSingleTargetState",
1045
+ value: function resetSingleTargetState(tmodel, key) {
1046
+ TargetUtil.resetTargetStateOnly(tmodel, key);
1047
+ tmodel.cancelAnimation();
1048
+ tmodel.activatedTargets.length = 0;
1049
+ }
1050
+ }, {
1051
+ key: "resetRemovedChildTarget",
1052
+ value: function resetRemovedChildTarget(tmodel, key, child) {
1053
+ var targetValue = tmodel.targetValues[key];
1054
+ if (!targetValue) {
1055
+ return;
1056
+ }
1057
+ TargetUtil.resetTargetStateOnly(tmodel, key);
1058
+ for (var _i2 = 0, _arr2 = ["childAction", "addChildAction"]; _i2 < _arr2.length; _i2++) {
1059
+ var _children$indexOf;
1060
+ var name = _arr2[_i2];
1061
+ var children = targetValue[name];
1062
+ var index = (_children$indexOf = children === null || children === void 0 ? void 0 : children.indexOf(child)) !== null && _children$indexOf !== void 0 ? _children$indexOf : -1;
1063
+ if (index >= 0) {
1064
+ children.splice(index, 1);
1065
+ }
1066
+ }
1067
+ }
1028
1068
  }, {
1029
1069
  key: "convertAnimatingTargetsToUpdating",
1030
1070
  value: function convertAnimatingTargetsToUpdating(tmodels) {
@@ -1066,6 +1106,27 @@ var TargetUtil = /*#__PURE__*/function () {
1066
1106
  clearChildActions: reset === 'tree' || reset === 'all'
1067
1107
  };
1068
1108
  }
1109
+ }, {
1110
+ key: "isTargetUpdating",
1111
+ value: function isTargetUpdating(tmodel, key) {
1112
+ var targetValue = tmodel.targetValues[key];
1113
+ if (!targetValue) {
1114
+ return false;
1115
+ }
1116
+ var valuePointer = tmodel.getValueListPointer(key);
1117
+ var cycle = tmodel.getTargetCycle(key);
1118
+ var cycles = tmodel.getTargetCycles(key);
1119
+ var step = tmodel.getTargetStep(key);
1120
+ var steps = tmodel.getTargetSteps(key);
1121
+ if (Array.isArray(targetValue.valueList) && valuePointer < targetValue.valueList.length) {
1122
+ return true;
1123
+ } else if (tmodel.isTargetImperative(key) && cycle < cycles - 1) {
1124
+ return true;
1125
+ } else if (step < steps) {
1126
+ return true;
1127
+ }
1128
+ return false;
1129
+ }
1069
1130
  }]);
1070
1131
  }();
1071
1132
  export { TargetUtil };
@@ -100,16 +100,14 @@ var VisibilityUtil = /*#__PURE__*/function () {
100
100
  }, {
101
101
  key: "getParentClip",
102
102
  value: function getParentClip(parent) {
103
- var _parent$$dom, _parent$$dom2;
104
- var domScrollLeft = ((_parent$$dom = parent.$dom) === null || _parent$$dom === void 0 ? void 0 : _parent$$dom.getScrollLeft()) || 0;
105
- var domScrollTop = ((_parent$$dom2 = parent.$dom) === null || _parent$$dom2 === void 0 ? void 0 : _parent$$dom2.getScrollTop()) || 0;
106
- var height = parent.getHeight();
107
- var width = parent.getWidth();
103
+ var _parent$$dom$getScrol, _parent$$dom, _parent$$dom$getScrol2, _parent$$dom2;
104
+ var domScrollLeft = (_parent$$dom$getScrol = (_parent$$dom = parent.$dom) === null || _parent$$dom === void 0 ? void 0 : _parent$$dom.getScrollLeft()) !== null && _parent$$dom$getScrol !== void 0 ? _parent$$dom$getScrol : 0;
105
+ var domScrollTop = (_parent$$dom$getScrol2 = (_parent$$dom2 = parent.$dom) === null || _parent$$dom2 === void 0 ? void 0 : _parent$$dom2.getScrollTop()) !== null && _parent$$dom$getScrol2 !== void 0 ? _parent$$dom$getScrol2 : 0;
108
106
  return {
109
107
  x: parent.absX + domScrollLeft,
110
108
  y: parent.absY + domScrollTop,
111
- r: parent.absX + width + domScrollLeft,
112
- b: parent.absY + height + domScrollTop,
109
+ r: parent.absX + parent.getWidth() + domScrollLeft,
110
+ b: parent.absY + parent.getHeight() + domScrollTop,
113
111
  source: parent
114
112
  };
115
113
  }
@@ -122,17 +120,30 @@ var VisibilityUtil = /*#__PURE__*/function () {
122
120
  }, {
123
121
  key: "intersectRects",
124
122
  value: function intersectRects(parent, a, b) {
125
- var _parent$$dom3, _parent$$dom4;
126
- var domScrollLeft = ((_parent$$dom3 = parent.$dom) === null || _parent$$dom3 === void 0 ? void 0 : _parent$$dom3.getScrollLeft()) || 0;
127
- var domScrollTop = ((_parent$$dom4 = parent.$dom) === null || _parent$$dom4 === void 0 ? void 0 : _parent$$dom4.getScrollTop()) || 0;
123
+ var _parent$$dom$getScrol3, _parent$$dom3, _parent$$dom$getScrol4, _parent$$dom4;
124
+ var scrollLeft = (_parent$$dom$getScrol3 = (_parent$$dom3 = parent.$dom) === null || _parent$$dom3 === void 0 ? void 0 : _parent$$dom3.getScrollLeft()) !== null && _parent$$dom$getScrol3 !== void 0 ? _parent$$dom$getScrol3 : 0;
125
+ var scrollTop = (_parent$$dom$getScrol4 = (_parent$$dom4 = parent.$dom) === null || _parent$$dom4 === void 0 ? void 0 : _parent$$dom4.getScrollTop()) !== null && _parent$$dom$getScrol4 !== void 0 ? _parent$$dom$getScrol4 : 0;
128
126
  return {
129
- x: Math.max(a.x - domScrollLeft, b.x - domScrollLeft),
130
- y: Math.max(a.y - domScrollTop, b.y - domScrollTop),
131
- r: Math.min(a.r - domScrollLeft, b.r - domScrollLeft),
132
- b: Math.min(a.b - domScrollTop, b.b - domScrollTop),
127
+ x: Math.max(a.x, b.x) - scrollLeft,
128
+ y: Math.max(a.y, b.y) - scrollTop,
129
+ r: Math.min(a.r, b.r) - scrollLeft,
130
+ b: Math.min(a.b, b.b) - scrollTop,
133
131
  source: b.source
134
132
  };
135
133
  }
134
+ }, {
135
+ key: "getUnappliedScroll",
136
+ value: function getUnappliedScroll(tmodel) {
137
+ var _tmodel$$dom$getScrol, _tmodel$$dom, _tmodel$$dom$getScrol2, _tmodel$$dom2, _tmodel$getScrollTop, _tmodel$getScrollLeft;
138
+ var domTop = (_tmodel$$dom$getScrol = (_tmodel$$dom = tmodel.$dom) === null || _tmodel$$dom === void 0 ? void 0 : _tmodel$$dom.getScrollTop()) !== null && _tmodel$$dom$getScrol !== void 0 ? _tmodel$$dom$getScrol : 0;
139
+ var domLeft = (_tmodel$$dom$getScrol2 = (_tmodel$$dom2 = tmodel.$dom) === null || _tmodel$$dom2 === void 0 ? void 0 : _tmodel$$dom2.getScrollLeft()) !== null && _tmodel$$dom$getScrol2 !== void 0 ? _tmodel$$dom$getScrol2 : 0;
140
+ var modelTop = (_tmodel$getScrollTop = tmodel.getScrollTop()) !== null && _tmodel$getScrollTop !== void 0 ? _tmodel$getScrollTop : 0;
141
+ var modelLeft = (_tmodel$getScrollLeft = tmodel.getScrollLeft()) !== null && _tmodel$getScrollLeft !== void 0 ? _tmodel$getScrollLeft : 0;
142
+ return {
143
+ x: Math.max(0, domLeft - modelLeft),
144
+ y: Math.max(0, domTop - modelTop)
145
+ };
146
+ }
136
147
  }]);
137
148
  }();
138
149
  export { VisibilityUtil };