targetj 1.0.187 → 1.0.188

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.
@@ -915,26 +915,6 @@ var BaseModel = exports.BaseModel = /*#__PURE__*/function () {
915
915
  }
916
916
  }
917
917
  }
918
- }, {
919
- key: "hasUpdatingChildren",
920
- value: function hasUpdatingChildren(originalTargetName) {
921
- if (originalTargetName) {
922
- var count = 0;
923
- this.updatingChildrenList.forEach(function (child) {
924
- child.updatingTargetList.forEach(function (target) {
925
- var _child$targetValues$t, _child$targets$target;
926
- if (child.isTargetImperative(target) && ((_child$targetValues$t = child.targetValues[target]) === null || _child$targetValues$t === void 0 ? void 0 : _child$targetValues$t.originalTargetName) === originalTargetName) {
927
- count++;
928
- } else if (((_child$targets$target = child.targets[target]) === null || _child$targets$target === void 0 ? void 0 : _child$targets$target.originalTargetName) === originalTargetName) {
929
- count++;
930
- }
931
- });
932
- });
933
- return count;
934
- } else {
935
- return this.updatingChildrenList.length > 0;
936
- }
937
- }
938
918
  }, {
939
919
  key: "addToActiveChildren",
940
920
  value: function addToActiveChildren(child) {
@@ -29,15 +29,21 @@ var LoadingManager = exports.LoadingManager = /*#__PURE__*/function () {
29
29
  this.fetchingImageMap = {};
30
30
  }
31
31
  return _createClass(LoadingManager, [{
32
+ key: "clear",
33
+ value: function clear() {
34
+ this.tmodelKeyMap = {};
35
+ this.fetchingAPIMap = {};
36
+ this.fetchingImageMap = {};
37
+ }
38
+ }, {
32
39
  key: "fetchCommon",
33
40
  value: function fetchCommon(fetchId, cacheId, tmodel, fetchMap, fetchFn) {
34
41
  _TargetUtil.TargetUtil.markTargetAction(tmodel, 'fetchAction');
35
- if (!cacheId || !this.isFetched(cacheId)) {
42
+ if (!this.isFetched(cacheId)) {
36
43
  if (!fetchMap[fetchId]) {
37
44
  fetchMap[fetchId] = {
38
45
  fetchId: fetchId,
39
46
  cacheId: cacheId,
40
- fetchingFlag: true,
41
47
  startTime: _TUtil.TUtil.now(),
42
48
  targets: [{
43
49
  tmodel: tmodel,
@@ -46,17 +52,11 @@ var LoadingManager = exports.LoadingManager = /*#__PURE__*/function () {
46
52
  fetchMap: fetchMap
47
53
  };
48
54
  fetchFn();
49
- } else {
50
- fetchMap[fetchId].targets.push({
51
- tmodel: tmodel,
52
- targetName: tmodel.key
53
- });
54
55
  }
55
56
  } else if (!fetchMap[fetchId]) {
56
57
  fetchMap[fetchId] = {
57
58
  fetchId: fetchId,
58
59
  cacheId: cacheId,
59
- fetchingFlag: true,
60
60
  startTime: _TUtil.TUtil.now(),
61
61
  targets: [{
62
62
  tmodel: tmodel,
@@ -113,8 +113,11 @@ var LoadingManager = exports.LoadingManager = /*#__PURE__*/function () {
113
113
  activeIndex: 0,
114
114
  accessIndex: 0
115
115
  };
116
+ }
117
+ if (!tmodel.val(loadTargetName)) {
116
118
  tmodel.val(loadTargetName, []);
117
119
  }
120
+ ;
118
121
  if (!this.tmodelKeyMap[key].fetchMap[fetchId]) {
119
122
  this.tmodelKeyMap[key].fetchMap[fetchId] = {
120
123
  fetchId: fetchId,
@@ -124,6 +127,7 @@ var LoadingManager = exports.LoadingManager = /*#__PURE__*/function () {
124
127
  tmodel.val(loadTargetName).push(undefined);
125
128
  }
126
129
  if (cacheId && this.isFetched(cacheId)) {
130
+ this.fetchingAPIMap[fetchId].startTime = _TUtil.TUtil.now();
127
131
  this.handleSuccess(this.fetchingAPIMap[fetchId], this.cacheMap[cacheId].result);
128
132
  }
129
133
  }
@@ -208,12 +212,6 @@ var LoadingManager = exports.LoadingManager = /*#__PURE__*/function () {
208
212
  }
209
213
  return result;
210
214
  }
211
- }, {
212
- key: "isFetching",
213
- value: function isFetching(fetchId) {
214
- var _this$fetchingAPIMap$, _this$fetchingAPIMap$2;
215
- return (_this$fetchingAPIMap$ = (_this$fetchingAPIMap$2 = this.fetchingAPIMap[fetchId]) === null || _this$fetchingAPIMap$2 === void 0 ? void 0 : _this$fetchingAPIMap$2.fetchingFlag) !== null && _this$fetchingAPIMap$ !== void 0 ? _this$fetchingAPIMap$ : false;
216
- }
217
215
  }, {
218
216
  key: "isFetched",
219
217
  value: function isFetched(cacheId) {
@@ -260,10 +258,12 @@ var LoadingManager = exports.LoadingManager = /*#__PURE__*/function () {
260
258
  }));
261
259
  var targetResults = tmodel.val(loadTargetName);
262
260
  if (targetResults) {
261
+ if (!targetResults[fetchEntry.order]) {
262
+ tmodelEntry.resultCount++;
263
+ }
263
264
  targetResults[fetchEntry.order] = res.result;
264
265
  }
265
266
  tmodel.val(targetName, (targetResults === null || targetResults === void 0 ? void 0 : targetResults.length) === 1 ? targetResults[0] : targetResults);
266
- tmodelEntry.resultCount++;
267
267
  _TargetUtil.TargetUtil.shouldActivateNextTarget(tmodel, targetName);
268
268
  });
269
269
  delete fetchMap[fetchId];
@@ -299,9 +299,13 @@ var LoadingManager = exports.LoadingManager = /*#__PURE__*/function () {
299
299
  error: error
300
300
  };
301
301
  var targetResults = tmodel.val(loadTargetName);
302
- targetResults[fetchEntry.order] = res;
302
+ if (targetResults) {
303
+ if (!targetResults[fetchEntry.order]) {
304
+ tmodelEntry.resultCount++;
305
+ }
306
+ targetResults[fetchEntry.order] = res;
307
+ }
303
308
  tmodel.val(targetName, targetResults.length === 1 ? targetResults[0] : targetResults);
304
- tmodelEntry.resultCount++;
305
309
  tmodelEntry.errorCount++;
306
310
  _this4.callOnErrorHandler(tmodel, targetName);
307
311
  _TargetUtil.TargetUtil.shouldActivateNextTarget(tmodel, targetName);
@@ -192,9 +192,11 @@ var RunScheduler = exports.RunScheduler = /*#__PURE__*/function () {
192
192
  this.defer("rerun-".concat(this.rerunId));
193
193
  } else {
194
194
  var newDelay = this.nextRuns.length > 0 ? this.nextRuns[0].delay - (_TUtil.TUtil.now() - this.nextRuns[0].insertTime) : undefined;
195
- if (newDelay === undefined || (0, _App.getManager)().lists.activeTModels.length > 0 || (0, _App.getManager)().lists.updatingTModels.length > 0) {
195
+ if (newDelay === undefined || (0, _App.getManager)().lists.activeTModels.length > 0 || (0, _App.getManager)().lists.updatingTModels.length > 0 || (0, _App.getLocationManager)().activatedList.length > 0) {
196
196
  if ((0, _App.getEvents)().eventQueue.length > 0) {
197
197
  this.schedule(15, "events-".concat((0, _App.getEvents)().eventQueue.length));
198
+ } else if ((0, _App.getLocationManager)().activatedList.length > 0) {
199
+ this.schedule(15, "getManager-locationManager-activatedList");
198
200
  } else if ((0, _App.getManager)().lists.updatingTModels.length > 0) {
199
201
  this.schedule(15, "getManager-needsRerun-updatingTModels");
200
202
  } else if ((0, _App.getManager)().lists.activeTModels.length > 0) {
@@ -6,10 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.TargetUtil = void 0;
7
7
  var _App = require("./App.js");
8
8
  var _TUtil = require("./TUtil.js");
9
+ var _TargetData = require("./TargetData.js");
9
10
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
10
- function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
11
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
12
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
13
11
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
14
12
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
15
13
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
@@ -130,11 +128,20 @@ var TargetUtil = exports.TargetUtil = /*#__PURE__*/function () {
130
128
  var target = tmodel.targets[key];
131
129
  var nextTarget = target === null || target === void 0 ? void 0 : target.activateNextTarget;
132
130
  if (!nextTarget || tmodel.isTargetImperative(key)) {
133
- var _ref = tmodel.isTargetImperative(key) ? tmodel.targetValues[key] : target,
134
- originalTModel = _ref.originalTModel,
135
- originalTargetName = _ref.originalTargetName;
136
- if (level < 2 && originalTargetName && originalTModel) {
137
- TargetUtil.shouldActivateNextTarget(originalTModel, originalTargetName, level + 1);
131
+ if (tmodel.isTargetImperative(key)) {
132
+ var _tmodel$targetValues$ = tmodel.targetValues[key],
133
+ originalTModel = _tmodel$targetValues$.originalTModel,
134
+ originalTargetName = _tmodel$targetValues$.originalTargetName;
135
+ if (originalTargetName && originalTModel) {
136
+ TargetUtil.shouldActivateNextTarget(originalTModel, originalTargetName, level + 1);
137
+ }
138
+ } else {
139
+ var _originalTModel$targe;
140
+ var _originalTModel = target.originalTModel,
141
+ _originalTargetName = target.originalTargetName;
142
+ if (_originalTargetName && _originalTModel && (_originalTModel$targe = _originalTModel.targets[_originalTargetName]) !== null && _originalTModel$targe !== void 0 && _originalTModel$targe.activateNextTarget) {
143
+ TargetUtil.shouldActivateNextTarget(_originalTModel, _originalTargetName, level + 1);
144
+ }
138
145
  }
139
146
  if (!tmodel.isTargetImperative(key)) {
140
147
  TargetUtil.cleanupTarget(tmodel, key);
@@ -148,15 +155,22 @@ var TargetUtil = exports.TargetUtil = /*#__PURE__*/function () {
148
155
  if (fetchAction) {
149
156
  if (fetchAction === 'onEnd' && TargetUtil.hasTargetEnded(tmodel, key)) {
150
157
  tmodel.activateTarget(cleanNextTarget);
158
+ return;
151
159
  } else if (fetchAction === 'onEach') {
160
+ var activateFlag = false;
152
161
  while ((0, _App.getLoader)().isNextLoadingItemSuccessful(tmodel, key)) {
153
162
  if (tmodel.activatedTargets.indexOf(cleanNextTarget) >= 0) {
154
163
  tmodel.activatedTargets.push(cleanNextTarget);
164
+ activateFlag = true;
155
165
  } else {
156
166
  tmodel.activateTarget(cleanNextTarget);
167
+ activateFlag = true;
157
168
  }
158
169
  (0, _App.getLoader)().nextActiveItem(tmodel, key);
159
170
  }
171
+ if (activateFlag) {
172
+ return;
173
+ }
160
174
  } else {
161
175
  TargetUtil.cleanupTarget(tmodel, key);
162
176
  }
@@ -170,12 +184,12 @@ var TargetUtil = exports.TargetUtil = /*#__PURE__*/function () {
170
184
  target.childAction = 'inactive';
171
185
  }
172
186
  }
173
- if (!childAction && !fetchAction && target && !tmodel.isTargetImperative(key)) {
187
+ if (!childAction && !fetchAction && target && cleanNextTarget && !tmodel.isTargetImperative(key)) {
174
188
  if (isEndTrigger && TargetUtil.hasTargetEnded(tmodel, key) || !isEndTrigger) {
175
189
  tmodel.activateTarget(cleanNextTarget);
176
190
  }
177
191
  }
178
- if (TargetUtil.hasTargetEnded(tmodel, key)) {
192
+ if (TargetUtil.isTargetComplete(tmodel, key)) {
179
193
  TargetUtil.cleanupTarget(tmodel, key);
180
194
  }
181
195
  }
@@ -221,37 +235,43 @@ var TargetUtil = exports.TargetUtil = /*#__PURE__*/function () {
221
235
  return true;
222
236
  }
223
237
  }, {
224
- key: "hasDeclarativeTargetUpdates",
225
- value: function hasDeclarativeTargetUpdates(tmodel) {
226
- if (!tmodel.hasTargetUpdates()) {
227
- return false;
228
- }
229
- var _iterator = _createForOfIteratorHelper(tmodel.updatingTargetList),
230
- _step;
231
- try {
232
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
233
- var target = _step.value;
234
- if (!tmodel.isTargetImperative(target)) {
235
- return true;
236
- }
238
+ key: "hasTargetEnded",
239
+ value: function hasTargetEnded(tmodel, key) {
240
+ return !TargetUtil.isTargetComplete(tmodel, key) || tmodel.hasUpdatingTargets(key) || !TargetUtil.arePreviousTargetsComplete(tmodel, key) ? false : true;
241
+ }
242
+ }, {
243
+ key: "arePreviousTargetsComplete",
244
+ value: function arePreviousTargetsComplete(tmodel, key) {
245
+ var keyIndex = tmodel.originalTargetNames.findIndex(function (name) {
246
+ return key === TargetUtil.getTargetName(name);
247
+ });
248
+ for (var i = 0; i < keyIndex; i++) {
249
+ var prevTarget = TargetUtil.getTargetName(tmodel.originalTargetNames[i]);
250
+ if (tmodel.isTargetImperative(prevTarget)) {
251
+ continue;
252
+ }
253
+ if (!TargetUtil.isTargetComplete(tmodel, prevTarget)) {
254
+ return false;
237
255
  }
238
- } catch (err) {
239
- _iterator.e(err);
240
- } finally {
241
- _iterator.f();
242
256
  }
243
- return false;
257
+ return true;
244
258
  }
245
259
  }, {
246
- key: "hasTargetEnded",
247
- value: function hasTargetEnded(tmodel, key) {
248
- var inProgress = !tmodel.isTargetComplete(key) && !tmodel.isTargetDone(key) || tmodel.hasUpdatingTargets(key) || TargetUtil.hasDeclarativeTargetUpdates(tmodel);
249
- if (inProgress) {
250
- return false;
251
- }
260
+ key: "isTargetComplete",
261
+ value: function isTargetComplete(tmodel, key) {
252
262
  var target = tmodel.targets[key];
253
263
  if (target) {
254
- if (target.childAction && (tmodel.hasUpdatingChildren(key) || tmodel.hasActiveChildren(key))) {
264
+ var targetType = _typeof(target.value);
265
+ if (_TargetData.TargetData.controlTargetMap[key]) {
266
+ return true;
267
+ }
268
+ if (!target.childAction && !target.fetchAction && (targetType === 'string' || targetType === 'number' || targetType === 'boolean')) {
269
+ return true;
270
+ }
271
+ if (!tmodel.isTargetComplete(key) && !tmodel.isTargetDone(key)) {
272
+ return false;
273
+ }
274
+ if (target.childAction && (TargetUtil.hasUpdatingChildren(tmodel, key) || tmodel.hasActiveChildren())) {
255
275
  return false;
256
276
  }
257
277
  if (target.fetchAction && !(0, _App.getLoader)().isLoadingSuccessful(tmodel, key)) {
@@ -260,6 +280,24 @@ var TargetUtil = exports.TargetUtil = /*#__PURE__*/function () {
260
280
  }
261
281
  return true;
262
282
  }
283
+ }, {
284
+ key: "hasUpdatingChildren",
285
+ value: function hasUpdatingChildren(tmodel, originalTargetName) {
286
+ var count = 0;
287
+ tmodel.updatingChildrenList.filter(function (child) {
288
+ return child.isVisible();
289
+ }).forEach(function (child) {
290
+ child.updatingTargetList.forEach(function (target) {
291
+ var _child$targetValues$t, _child$targets$target;
292
+ if (child.isTargetImperative(target) && ((_child$targetValues$t = child.targetValues[target]) === null || _child$targetValues$t === void 0 ? void 0 : _child$targetValues$t.originalTargetName) === originalTargetName) {
293
+ count++;
294
+ } else if (((_child$targets$target = child.targets[target]) === null || _child$targets$target === void 0 ? void 0 : _child$targets$target.originalTargetName) === originalTargetName) {
295
+ count++;
296
+ }
297
+ });
298
+ });
299
+ return count;
300
+ }
263
301
  }, {
264
302
  key: "activateSingleTarget",
265
303
  value: function activateSingleTarget(tmodel, targetName) {