targetj 1.0.237 → 1.0.238

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.
@@ -1175,9 +1175,9 @@ var BaseModel = exports.BaseModel = /*#__PURE__*/function () {
1175
1175
  actualOptions = value;
1176
1176
  }
1177
1177
  if (this.canTargetBeActivated(key)) {
1178
- var _actualOptions;
1179
- if ((_actualOptions = actualOptions) !== null && _actualOptions !== void 0 && _actualOptions.reset) {
1180
- _TargetUtil.TargetUtil.resetTargetState(this, key);
1178
+ var resetOptions = _TargetUtil.TargetUtil.getResetOptions(actualOptions);
1179
+ if (resetOptions.shouldReset) {
1180
+ _TargetUtil.TargetUtil.resetTargetState(this, key, resetOptions);
1181
1181
  }
1182
1182
  if (_TUtil.TUtil.isDefined(actualValue)) {
1183
1183
  this.val("___".concat(key), actualValue);
@@ -689,44 +689,33 @@ var TargetUtil = exports.TargetUtil = /*#__PURE__*/function () {
689
689
  }, {
690
690
  key: "resetTargetState",
691
691
  value: function resetTargetState(tmodel, targetName) {
692
- var visited = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new Set();
692
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
693
+ var visited = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new Set();
693
694
  if (!tmodel || !targetName) {
694
695
  return;
695
696
  }
696
697
  TargetUtil.resetSingleTargetState(tmodel, targetName);
698
+ TargetUtil.resetTargetChildActions(tmodel, targetName, options, visited);
697
699
  var target = tmodel.targets[targetName];
698
700
  var nextTarget = target === null || target === void 0 ? void 0 : target.activateNextTarget;
699
701
  var nextTargetDef = tmodel.targets[nextTarget];
700
702
  if (!nextTargetDef || !nextTarget.endsWith('$') && nextTargetDef.active === false) {
701
703
  return;
702
704
  }
703
- TargetUtil.resetTargetsBetween(tmodel, targetName, nextTarget, visited);
704
- TargetUtil.resetTargetPipelineState(tmodel, nextTarget, visited);
705
+ TargetUtil.resetTargetsBetween(tmodel, targetName, nextTarget, options, visited);
706
+ TargetUtil.resetTargetPipelineState(tmodel, nextTarget, options, visited);
705
707
  }
706
708
  }, {
707
709
  key: "resetTargetPipelineState",
708
710
  value: function resetTargetPipelineState(tmodel, targetName) {
709
- var _target$childAction4, _target$addChildActio;
710
- var visited = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new Set();
711
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
712
+ var visited = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new Set();
711
713
  if (!tmodel || !targetName) {
712
714
  return;
713
715
  }
714
- var target = tmodel.targets[targetName];
715
716
  TargetUtil.resetSingleTargetState(tmodel, targetName);
716
- if ((_target$childAction4 = target.childAction) !== null && _target$childAction4 !== void 0 && _target$childAction4.length) {
717
- target.childAction.forEach(function (child) {
718
- if (child) {
719
- TargetUtil.resetTargetChildState(child, visited);
720
- }
721
- });
722
- }
723
- if ((_target$addChildActio = target.addChildAction) !== null && _target$addChildActio !== void 0 && _target$addChildActio.length) {
724
- target.addChildAction.forEach(function (child) {
725
- if (child) {
726
- TargetUtil.resetTargetChildState(child, visited);
727
- }
728
- });
729
- }
717
+ TargetUtil.resetTargetChildActions(tmodel, targetName, options, visited);
718
+ var target = tmodel.targets[targetName];
730
719
  var nextTarget = target === null || target === void 0 ? void 0 : target.activateNextTarget;
731
720
  if (!nextTarget) {
732
721
  return;
@@ -735,12 +724,14 @@ var TargetUtil = exports.TargetUtil = /*#__PURE__*/function () {
735
724
  if (!nextTargetDef || !nextTarget.endsWith('$') && nextTargetDef.active === false) {
736
725
  return;
737
726
  }
738
- TargetUtil.resetTargetsBetween(tmodel, targetName, nextTarget, visited);
739
- TargetUtil.resetTargetPipelineState(tmodel, nextTarget, visited);
727
+ TargetUtil.resetTargetsBetween(tmodel, targetName, nextTarget, options, visited);
728
+ TargetUtil.resetTargetPipelineState(tmodel, nextTarget, options, visited);
740
729
  }
741
730
  }, {
742
731
  key: "resetTargetsBetween",
743
- value: function resetTargetsBetween(tmodel, fromTarget, toTarget, visited) {
732
+ value: function resetTargetsBetween(tmodel, fromTarget, toTarget) {
733
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
734
+ var visited = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : new Set();
744
735
  var names = tmodel.functionTargetNames;
745
736
  var fromIndex = names.indexOf(fromTarget);
746
737
  var toIndex = names.indexOf(toTarget);
@@ -748,29 +739,16 @@ var TargetUtil = exports.TargetUtil = /*#__PURE__*/function () {
748
739
  return;
749
740
  }
750
741
  for (var i = fromIndex + 1; i < toIndex; i++) {
751
- var _target$childAction5, _target$addChildActio2;
752
742
  var key = names[i];
753
743
  TargetUtil.resetSingleTargetState(tmodel, key);
754
- var target = tmodel.targets[key];
755
- if (target !== null && target !== void 0 && (_target$childAction5 = target.childAction) !== null && _target$childAction5 !== void 0 && _target$childAction5.length) {
756
- target.childAction.forEach(function (child) {
757
- if (child) {
758
- TargetUtil.resetTargetChildState(child, visited);
759
- }
760
- });
761
- }
762
- if (target !== null && target !== void 0 && (_target$addChildActio2 = target.addChildAction) !== null && _target$addChildActio2 !== void 0 && _target$addChildActio2.length) {
763
- target.addChildAction.forEach(function (child) {
764
- if (child) {
765
- TargetUtil.resetTargetChildState(child, visited);
766
- }
767
- });
768
- }
744
+ TargetUtil.resetTargetChildActions(tmodel, key, options, visited);
769
745
  }
770
746
  }
771
747
  }, {
772
748
  key: "resetTargetChildState",
773
- value: function resetTargetChildState(tmodel, visited) {
749
+ value: function resetTargetChildState(tmodel) {
750
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
751
+ var visited = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new Set();
774
752
  var sig = "".concat(tmodel.oid);
775
753
  if (visited.has(sig)) {
776
754
  return;
@@ -778,25 +756,38 @@ var TargetUtil = exports.TargetUtil = /*#__PURE__*/function () {
778
756
  visited.add(sig);
779
757
  var names = Object.keys(tmodel.targetValues);
780
758
  for (var i = 0; i < names.length; i++) {
781
- var _target$childAction6, _target$addChildActio3;
782
759
  var key = names[i];
783
- var target = tmodel.targets[key];
784
760
  TargetUtil.resetSingleTargetState(tmodel, key);
785
- if (target !== null && target !== void 0 && (_target$childAction6 = target.childAction) !== null && _target$childAction6 !== void 0 && _target$childAction6.length) {
786
- target.childAction.forEach(function (child) {
787
- if (child) {
788
- TargetUtil.resetTargetChildState(child, visited);
789
- }
790
- });
791
- target.childAction = [];
761
+ TargetUtil.resetTargetChildActions(tmodel, key, options, visited);
762
+ }
763
+ }
764
+ }, {
765
+ key: "resetTargetChildActions",
766
+ value: function resetTargetChildActions(tmodel, key) {
767
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
768
+ var visited = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new Set();
769
+ var target = tmodel.targets[key];
770
+ if (!target) {
771
+ return;
772
+ }
773
+ var childActions = target.childAction ? _toConsumableArray(target.childAction) : [];
774
+ var addChildActions = target.addChildAction ? _toConsumableArray(target.addChildAction) : [];
775
+ childActions.forEach(function (child) {
776
+ if (child) {
777
+ TargetUtil.resetTargetChildState(child, options, visited);
792
778
  }
793
- if (target !== null && target !== void 0 && (_target$addChildActio3 = target.addChildAction) !== null && _target$addChildActio3 !== void 0 && _target$addChildActio3.length) {
794
- target.addChildAction.forEach(function (child) {
795
- if (child) {
796
- TargetUtil.resetTargetChildState(child, visited);
797
- }
798
- });
799
- target.addChildAction = [];
779
+ });
780
+ addChildActions.forEach(function (child) {
781
+ if (child) {
782
+ TargetUtil.resetTargetChildState(child, options, visited);
783
+ }
784
+ });
785
+ if (options.clearChildActions) {
786
+ if (Array.isArray(target.childAction)) {
787
+ target.childAction.length = 0;
788
+ }
789
+ if (Array.isArray(target.addChildAction)) {
790
+ target.addChildAction.length = 0;
800
791
  }
801
792
  }
802
793
  }
@@ -819,25 +810,13 @@ var TargetUtil = exports.TargetUtil = /*#__PURE__*/function () {
819
810
  TargetUtil.clearPendingTarget(tmodel, key);
820
811
  }
821
812
  }, {
822
- key: "removeChildFromTargetActions",
823
- value: function removeChildFromTargetActions(parent, child) {
824
- if (!parent || !child) {
825
- return;
826
- }
827
- for (var _i2 = 0, _Object$values = Object.values(parent.targets); _i2 < _Object$values.length; _i2++) {
828
- var _target$childAction7, _target$addChildActio4;
829
- var target = _Object$values[_i2];
830
- if ((_target$childAction7 = target.childAction) !== null && _target$childAction7 !== void 0 && _target$childAction7.length) {
831
- target.childAction = target.childAction.filter(function (c) {
832
- return c !== child;
833
- });
834
- }
835
- if ((_target$addChildActio4 = target.addChildAction) !== null && _target$addChildActio4 !== void 0 && _target$addChildActio4.length) {
836
- target.addChildAction = target.addChildAction.filter(function (c) {
837
- return c !== child;
838
- });
839
- }
840
- }
813
+ key: "getResetOptions",
814
+ value: function getResetOptions(options) {
815
+ var reset = options === null || options === void 0 ? void 0 : options.reset;
816
+ return {
817
+ shouldReset: reset === true || reset === 'pipeline' || reset === 'tree' || reset === 'all',
818
+ clearChildActions: reset === 'tree' || reset === 'all'
819
+ };
841
820
  }
842
821
  }]);
843
822
  }();