targetj 1.0.74 → 1.0.76
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/babel.config.json +17 -0
- package/build/$Dom.js +424 -0
- package/build/App.js +187 -0
- package/build/Bracket.js +157 -0
- package/build/BracketGenerator.js +86 -0
- package/build/Browser.js +105 -0
- package/build/ColorUtil.js +182 -0
- package/build/Dim.js +31 -0
- package/build/Easing.js +59 -0
- package/build/EventListener.js +664 -0
- package/build/LoadingManager.js +366 -0
- package/build/LocationManager.js +211 -0
- package/build/Moves.js +71 -0
- package/build/PageManager.js +113 -0
- package/build/SearchUtil.js +196 -0
- package/build/TModel.js +1000 -0
- package/build/TModelManager.js +605 -0
- package/build/TUtil.js +188 -0
- package/build/TargetExecutor.js +117 -0
- package/build/TargetManager.js +197 -0
- package/build/TargetUtil.js +299 -0
- package/build/Viewport.js +163 -0
- package/package.json +11 -4
- package/webpack.config.js +14 -1
- package/src/$Dom.js +0 -380
- package/src/App.js +0 -224
- package/src/Bracket.js +0 -212
- package/src/Browser.js +0 -122
- package/src/ColorUtil.js +0 -166
- package/src/Dim.js +0 -21
- package/src/Easing.js +0 -41
- package/src/EventListener.js +0 -570
- package/src/LoadingManager.js +0 -368
- package/src/LocationManager.js +0 -236
- package/src/Moves.js +0 -59
- package/src/PageManager.js +0 -87
- package/src/SearchUtil.js +0 -210
- package/src/TModel.js +0 -937
- package/src/TModelManager.js +0 -575
- package/src/TUtil.js +0 -162
- package/src/TargetExecutor.js +0 -113
- package/src/TargetManager.js +0 -191
- package/src/TargetUtil.js +0 -307
- package/src/Viewport.js +0 -180
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.LoadingManager = void 0;
|
|
7
|
+
var _$Dom = require("./$Dom.js");
|
|
8
|
+
var _Browser = require("./Browser.js");
|
|
9
|
+
var _TUtil = require("./TUtil.js");
|
|
10
|
+
var _App = require("./App.js");
|
|
11
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
14
|
+
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); }
|
|
15
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
16
|
+
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); } }
|
|
17
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
18
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
19
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
20
|
+
var LoadingManager = exports.LoadingManager = /*#__PURE__*/function () {
|
|
21
|
+
function LoadingManager() {
|
|
22
|
+
_classCallCheck(this, LoadingManager);
|
|
23
|
+
this.resultMap = {};
|
|
24
|
+
this.loadingMap = {};
|
|
25
|
+
this.singleLoadList = undefined;
|
|
26
|
+
this.groupLoadList = undefined;
|
|
27
|
+
this.imgLoadList = undefined;
|
|
28
|
+
this.stopLoadingAfterAttempts = _TUtil.TUtil.isDefined(_App.tApp.stopLoadingAfterAttempts) ? _App.tApp.stopLoadingAfterAttempts : 10;
|
|
29
|
+
this.attemptFailedInterval = _TUtil.TUtil.isDefined(_App.tApp.attemptFailedInterval) ? _App.tApp.attemptFailedInterval : 2000;
|
|
30
|
+
this.statistics = {};
|
|
31
|
+
}
|
|
32
|
+
return _createClass(LoadingManager, [{
|
|
33
|
+
key: "initSingleLoad",
|
|
34
|
+
value: function initSingleLoad(fetchId, query, forceLoad) {
|
|
35
|
+
if (this.isLoading(fetchId) || this.isLoaded(fetchId) && !forceLoad || this.getLoadingAttempts(fetchId) > this.stopLoadingAfterAttempts) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
this.initLoadingMap(fetchId);
|
|
39
|
+
this.singleLoadList = this.singleLoadList || {};
|
|
40
|
+
this.singleLoadList[fetchId] = {
|
|
41
|
+
fetchId: fetchId,
|
|
42
|
+
query: query
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}, {
|
|
46
|
+
key: "initGroupLoad",
|
|
47
|
+
value: function initGroupLoad(fetchId, dataId, query, idKey, separator) {
|
|
48
|
+
var groupId = JSON.stringify({
|
|
49
|
+
query: query,
|
|
50
|
+
idKey: idKey,
|
|
51
|
+
separator: separator
|
|
52
|
+
});
|
|
53
|
+
if (this.isLoading(fetchId) || this.isLoaded(fetchId) || this.getLoadingAttempts(fetchId) > this.stopLoadingAfterAttempts) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
this.initLoadingMap(fetchId);
|
|
57
|
+
this.groupLoadList = this.groupLoadList || {};
|
|
58
|
+
if (!this.groupLoadList[groupId]) {
|
|
59
|
+
this.groupLoadList[groupId] = [];
|
|
60
|
+
}
|
|
61
|
+
this.groupLoadList[groupId].push({
|
|
62
|
+
fetchId: fetchId,
|
|
63
|
+
dataId: dataId
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}, {
|
|
67
|
+
key: "initImgLoad",
|
|
68
|
+
value: function initImgLoad(fetchId, src) {
|
|
69
|
+
if (this.isLoading(fetchId) || this.isLoaded(fetchId) || this.getLoadingAttempts(fetchId) > this.stopLoadingAfterAttempts) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
this.initLoadingMap(fetchId, 'image');
|
|
73
|
+
this.imgLoadList = this.imgLoadList || {};
|
|
74
|
+
this.imgLoadList[fetchId] = {
|
|
75
|
+
fetchId: fetchId,
|
|
76
|
+
src: src
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}, {
|
|
80
|
+
key: "isLoading",
|
|
81
|
+
value: function isLoading(fetchId) {
|
|
82
|
+
return _TUtil.TUtil.isDefined(this.loadingMap[fetchId]) ? this.loadingMap[fetchId].loadingFlag : false;
|
|
83
|
+
}
|
|
84
|
+
}, {
|
|
85
|
+
key: "isLoaded",
|
|
86
|
+
value: function isLoaded(fetchId) {
|
|
87
|
+
return _TUtil.TUtil.isDefined(this.resultMap[fetchId]) && this.resultMap[fetchId].success === true;
|
|
88
|
+
}
|
|
89
|
+
}, {
|
|
90
|
+
key: "getLoadingAttempts",
|
|
91
|
+
value: function getLoadingAttempts(fetchId) {
|
|
92
|
+
return _TUtil.TUtil.isDefined(this.loadingMap[fetchId]) ? this.loadingMap[fetchId].attempts : 0;
|
|
93
|
+
}
|
|
94
|
+
}, {
|
|
95
|
+
key: "getSuccessLoadingTime",
|
|
96
|
+
value: function getSuccessLoadingTime(fetchId) {
|
|
97
|
+
return _TUtil.TUtil.isDefined(this.loadingMap[fetchId]) && this.loadingMap[fetchId].success === true ? this.loadingMap[fetchId].loadingTime : undefined;
|
|
98
|
+
}
|
|
99
|
+
}, {
|
|
100
|
+
key: "getFailedInterval",
|
|
101
|
+
value: function getFailedInterval(fetchId) {
|
|
102
|
+
return _TUtil.TUtil.isDefined(this.loadingMap[fetchId]) ? this.loadingMap[fetchId].attempts * this.attemptFailedInterval : 0;
|
|
103
|
+
}
|
|
104
|
+
}, {
|
|
105
|
+
key: "fetchResult",
|
|
106
|
+
value: function fetchResult(fetchId) {
|
|
107
|
+
return this.resultMap[fetchId];
|
|
108
|
+
}
|
|
109
|
+
}, {
|
|
110
|
+
key: "hasLoadedSuccessfully",
|
|
111
|
+
value: function hasLoadedSuccessfully(fetchId) {
|
|
112
|
+
return this.resultMap[fetchId] && this.resultMap[fetchId].success === true;
|
|
113
|
+
}
|
|
114
|
+
}, {
|
|
115
|
+
key: "hasLoadedUnsuccessfully",
|
|
116
|
+
value: function hasLoadedUnsuccessfully(fetchId) {
|
|
117
|
+
return this.resultMap[fetchId] && this.resultMap[fetchId].success === false;
|
|
118
|
+
}
|
|
119
|
+
}, {
|
|
120
|
+
key: "fetchErrors",
|
|
121
|
+
value: function fetchErrors(fetchId) {
|
|
122
|
+
var _this$resultMap$fetch;
|
|
123
|
+
return (_this$resultMap$fetch = this.resultMap[fetchId]) === null || _this$resultMap$fetch === void 0 || (_this$resultMap$fetch = _this$resultMap$fetch.result) === null || _this$resultMap$fetch === void 0 ? void 0 : _this$resultMap$fetch.errors;
|
|
124
|
+
}
|
|
125
|
+
}, {
|
|
126
|
+
key: "initLoadingMap",
|
|
127
|
+
value: function initLoadingMap(fetchId, category) {
|
|
128
|
+
category = category || this.getCategoryFromFetchId(fetchId);
|
|
129
|
+
if (_TUtil.TUtil.isDefined(this.loadingMap[fetchId])) {
|
|
130
|
+
Object.assign(this.loadingMap[fetchId], {
|
|
131
|
+
loadingFlag: true,
|
|
132
|
+
startTime: _Browser.browser.now(),
|
|
133
|
+
loadingTime: undefined
|
|
134
|
+
});
|
|
135
|
+
} else {
|
|
136
|
+
this.loadingMap[fetchId] = {
|
|
137
|
+
fetchId: fetchId,
|
|
138
|
+
category: category,
|
|
139
|
+
loadingFlag: true,
|
|
140
|
+
attempts: 0,
|
|
141
|
+
startTime: _Browser.browser.now(),
|
|
142
|
+
loadingTime: undefined,
|
|
143
|
+
success: false
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}, {
|
|
148
|
+
key: "groupLoad",
|
|
149
|
+
value: function groupLoad() {
|
|
150
|
+
var _this = this;
|
|
151
|
+
if (!this.groupLoadList) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
var groupIds = Object.keys(this.groupLoadList);
|
|
155
|
+
groupIds.forEach(function (groupId) {
|
|
156
|
+
var fetchList = _this.groupLoadList[groupId];
|
|
157
|
+
var dataIds = [];
|
|
158
|
+
var dataIdFetchIdMap = {};
|
|
159
|
+
fetchList.forEach(function (_ref) {
|
|
160
|
+
var dataId = _ref.dataId,
|
|
161
|
+
fetchId = _ref.fetchId;
|
|
162
|
+
dataIds.push(dataId);
|
|
163
|
+
dataIdFetchIdMap[dataId] = fetchId;
|
|
164
|
+
});
|
|
165
|
+
if (dataIds.length > 0) {
|
|
166
|
+
var groupObj = JSON.parse(groupId);
|
|
167
|
+
var groupQuery = _this.updateQueryValue(groupObj.query, dataIds.join(groupObj.separator));
|
|
168
|
+
_this.groupAjax(groupQuery, dataIdFetchIdMap, groupObj.idKey);
|
|
169
|
+
}
|
|
170
|
+
delete _this.groupLoadList[groupId];
|
|
171
|
+
});
|
|
172
|
+
this.groupLoadList = undefined;
|
|
173
|
+
}
|
|
174
|
+
}, {
|
|
175
|
+
key: "singleLoad",
|
|
176
|
+
value: function singleLoad() {
|
|
177
|
+
var _this2 = this;
|
|
178
|
+
if (!this.singleLoadList) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
Object.values(this.singleLoadList).forEach(function (_ref2) {
|
|
182
|
+
var query = _ref2.query,
|
|
183
|
+
fetchId = _ref2.fetchId;
|
|
184
|
+
_this2.singleAjax(query, fetchId);
|
|
185
|
+
});
|
|
186
|
+
this.singleLoadList = undefined;
|
|
187
|
+
}
|
|
188
|
+
}, {
|
|
189
|
+
key: "imgLoad",
|
|
190
|
+
value: function imgLoad() {
|
|
191
|
+
var _this3 = this;
|
|
192
|
+
if (!this.imgLoadList) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
Object.values(this.imgLoadList).forEach(function (_ref3) {
|
|
196
|
+
var src = _ref3.src,
|
|
197
|
+
fetchId = _ref3.fetchId;
|
|
198
|
+
_this3.imgAjax(src, fetchId);
|
|
199
|
+
});
|
|
200
|
+
this.imgLoadList = undefined;
|
|
201
|
+
}
|
|
202
|
+
}, {
|
|
203
|
+
key: "updateQueryValue",
|
|
204
|
+
value: function updateQueryValue(query, value) {
|
|
205
|
+
var _this4 = this;
|
|
206
|
+
Object.keys(query).forEach(function (prop) {
|
|
207
|
+
if (query[prop] === '%s') {
|
|
208
|
+
query[prop] = value;
|
|
209
|
+
} else if (query[prop] === '%d') {
|
|
210
|
+
query[prop] = typeof value === 'number' ? value : parseFloat(value);
|
|
211
|
+
} else if (_typeof(query[prop]) === 'object') {
|
|
212
|
+
_this4.updateQueryValue(query[prop], value);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
return query;
|
|
216
|
+
}
|
|
217
|
+
}, {
|
|
218
|
+
key: "singleAjax",
|
|
219
|
+
value: function singleAjax(query, fetchId) {
|
|
220
|
+
var _this5 = this;
|
|
221
|
+
var defaultQuery = {
|
|
222
|
+
dataType: "json",
|
|
223
|
+
type: "GET",
|
|
224
|
+
success: function success(dataList) {
|
|
225
|
+
_this5.updateLoadStatus(fetchId, true);
|
|
226
|
+
_this5.resultMap[fetchId] = _objectSpread(_objectSpread({}, _this5.loadingMap[fetchId]), {}, {
|
|
227
|
+
result: dataList
|
|
228
|
+
});
|
|
229
|
+
_this5.updateStatistics(fetchId);
|
|
230
|
+
_App.tApp.manager.scheduleRun(0, "singleAjax_success_".concat(fetchId));
|
|
231
|
+
},
|
|
232
|
+
error: function error(textStatus) {
|
|
233
|
+
_this5.resultMap[fetchId] = {
|
|
234
|
+
error: textStatus,
|
|
235
|
+
success: false
|
|
236
|
+
};
|
|
237
|
+
_this5.updateLoadStatus(fetchId, false);
|
|
238
|
+
_App.tApp.manager.scheduleRun(0, "singleAjax_error_".concat(fetchId));
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
_$Dom.$Dom.ajax(_objectSpread(_objectSpread({}, defaultQuery), query));
|
|
242
|
+
}
|
|
243
|
+
}, {
|
|
244
|
+
key: "groupAjax",
|
|
245
|
+
value: function groupAjax(query, dataIdFetchIdMap, idKey) {
|
|
246
|
+
var _this6 = this;
|
|
247
|
+
var defaultQuery = {
|
|
248
|
+
dataType: "json",
|
|
249
|
+
type: "GET",
|
|
250
|
+
success: function success(dataList) {
|
|
251
|
+
dataList.forEach(function (data) {
|
|
252
|
+
var dataId = data[idKey];
|
|
253
|
+
if (dataIdFetchIdMap[dataId]) {
|
|
254
|
+
var fetchId = dataIdFetchIdMap[dataId];
|
|
255
|
+
_this6.updateLoadStatus(fetchId, true);
|
|
256
|
+
_this6.resultMap[fetchId] = _objectSpread(_objectSpread({}, _this6.loadingMap[fetchId]), {}, {
|
|
257
|
+
result: data
|
|
258
|
+
});
|
|
259
|
+
_this6.updateStatistics(fetchId);
|
|
260
|
+
delete dataIdFetchIdMap[dataId];
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
Object.keys(dataIdFetchIdMap).forEach(function (dataId) {
|
|
264
|
+
var fetchId = dataIdFetchIdMap[dataId];
|
|
265
|
+
if (!_this6.loadingMap[fetchId].success) {
|
|
266
|
+
_this6.updateLoadStatus(fetchId, false);
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
_App.tApp.manager.scheduleRun(0, "groupAjax_success_".concat(query));
|
|
270
|
+
},
|
|
271
|
+
error: function error(textStatus) {
|
|
272
|
+
Object.keys(dataIdFetchIdMap).forEach(function (dataId) {
|
|
273
|
+
var fetchId = dataIdFetchIdMap[dataId];
|
|
274
|
+
_this6.resultMap[fetchId] = {
|
|
275
|
+
error: textStatus,
|
|
276
|
+
success: false
|
|
277
|
+
};
|
|
278
|
+
_this6.updateLoadStatus(fetchId, false);
|
|
279
|
+
});
|
|
280
|
+
_App.tApp.manager.scheduleRun(0, "groupAjax_error_".concat(query));
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
_$Dom.$Dom.ajax(_objectSpread(_objectSpread({}, defaultQuery), query));
|
|
284
|
+
}
|
|
285
|
+
}, {
|
|
286
|
+
key: "imgAjax",
|
|
287
|
+
value: function imgAjax(src, fetchId) {
|
|
288
|
+
var _this7 = this;
|
|
289
|
+
var image = new Image();
|
|
290
|
+
image.src = src;
|
|
291
|
+
image.onload = function () {
|
|
292
|
+
_this7.updateLoadStatus(fetchId, true);
|
|
293
|
+
_this7.resultMap[fetchId] = _objectSpread(_objectSpread({}, _this7.loadingMap[fetchId]), {}, {
|
|
294
|
+
width: image.width,
|
|
295
|
+
height: image.height,
|
|
296
|
+
$image: new _$Dom.$Dom(image)
|
|
297
|
+
});
|
|
298
|
+
_this7.updateStatistics(fetchId, 'image');
|
|
299
|
+
_App.tApp.manager.scheduleRun(0, "imgAjax_success_".concat(fetchId));
|
|
300
|
+
};
|
|
301
|
+
image.onerror = image.onabort = function () {
|
|
302
|
+
_this7.resultMap[fetchId] = {
|
|
303
|
+
result: "no image",
|
|
304
|
+
success: false
|
|
305
|
+
};
|
|
306
|
+
_this7.updateLoadStatus(fetchId, false);
|
|
307
|
+
_App.tApp.manager.scheduleRun(0, "imgAjax_error_".concat(fetchId));
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
}, {
|
|
311
|
+
key: "getCategoryFromFetchId",
|
|
312
|
+
value: function getCategoryFromFetchId(fetchId) {
|
|
313
|
+
return fetchId.replace(/[^a-zA-Z]/g, '');
|
|
314
|
+
}
|
|
315
|
+
}, {
|
|
316
|
+
key: "updateStatistics",
|
|
317
|
+
value: function updateStatistics(fetchId, category) {
|
|
318
|
+
category = category || this.getCategoryFromFetchId(fetchId);
|
|
319
|
+
if (this.statistics[category]) {
|
|
320
|
+
this.statistics[category].count++;
|
|
321
|
+
this.statistics[category].totalTime += this.resultMap[fetchId].loadingTime;
|
|
322
|
+
this.statistics[category].lastUpdate = _Browser.browser.now();
|
|
323
|
+
delete this.statistics[category].averageTime;
|
|
324
|
+
} else {
|
|
325
|
+
this.statistics[category] = {
|
|
326
|
+
count: 1,
|
|
327
|
+
totalTime: this.resultMap[fetchId].loadingTime,
|
|
328
|
+
lastUpdate: _Browser.browser.now()
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}, {
|
|
333
|
+
key: "getAverageLoadingTime",
|
|
334
|
+
value: function getAverageLoadingTime(category) {
|
|
335
|
+
var _this$statistics$cate, _this$statistics$cate2, _this$statistics$cate3;
|
|
336
|
+
var now = _Browser.browser.now();
|
|
337
|
+
if ((_this$statistics$cate = this.statistics[category]) !== null && _this$statistics$cate !== void 0 && _this$statistics$cate.averageTime && now - this.statistics[category].lastUpdate < 500) {
|
|
338
|
+
return this.statistics[category].averageTime;
|
|
339
|
+
}
|
|
340
|
+
var totalTime = ((_this$statistics$cate2 = this.statistics[category]) === null || _this$statistics$cate2 === void 0 ? void 0 : _this$statistics$cate2.totalTime) || 0;
|
|
341
|
+
var count = ((_this$statistics$cate3 = this.statistics[category]) === null || _this$statistics$cate3 === void 0 ? void 0 : _this$statistics$cate3.count) || 0;
|
|
342
|
+
Object.values(this.loadingMap).filter(function (loadItem) {
|
|
343
|
+
return loadItem.category === category;
|
|
344
|
+
}).forEach(function (loadItem) {
|
|
345
|
+
totalTime += now - loadItem.startTime;
|
|
346
|
+
count++;
|
|
347
|
+
});
|
|
348
|
+
if (this.statistics[category]) {
|
|
349
|
+
this.statistics[category].averageTime = count > 0 ? totalTime / count : 0;
|
|
350
|
+
this.statistics[category].lastUpdate = _Browser.browser.now();
|
|
351
|
+
return this.statistics[category].averageTime;
|
|
352
|
+
}
|
|
353
|
+
return 0;
|
|
354
|
+
}
|
|
355
|
+
}, {
|
|
356
|
+
key: "updateLoadStatus",
|
|
357
|
+
value: function updateLoadStatus(fetchId, success) {
|
|
358
|
+
Object.assign(this.loadingMap[fetchId], {
|
|
359
|
+
loadingFlag: false,
|
|
360
|
+
loadingTime: _Browser.browser.now() - this.loadingMap[fetchId].startTime,
|
|
361
|
+
success: success,
|
|
362
|
+
attempts: this.loadingMap[fetchId].attempts + 1
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
}]);
|
|
366
|
+
}();
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.LocationManager = void 0;
|
|
7
|
+
var _BracketGenerator = require("./BracketGenerator.js");
|
|
8
|
+
var _TUtil = require("./TUtil.js");
|
|
9
|
+
var _TargetUtil = require("./TargetUtil.js");
|
|
10
|
+
var _TargetExecutor = require("./TargetExecutor.js");
|
|
11
|
+
var _App = require("./App.js");
|
|
12
|
+
var _Browser = require("./Browser.js");
|
|
13
|
+
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); }
|
|
14
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
15
|
+
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); } }
|
|
16
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
17
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
18
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
19
|
+
var LocationManager = exports.LocationManager = /*#__PURE__*/function () {
|
|
20
|
+
function LocationManager() {
|
|
21
|
+
_classCallCheck(this, LocationManager);
|
|
22
|
+
this.hasLocationList = [];
|
|
23
|
+
this.hasLocationMap = {};
|
|
24
|
+
this.bracketThreshold = 6;
|
|
25
|
+
this.locationCount = [];
|
|
26
|
+
this.screenWidth = (0, _App.getScreenWidth)();
|
|
27
|
+
this.screenHeight = (0, _App.getScreenHeight)();
|
|
28
|
+
this.resizeFlag = false;
|
|
29
|
+
}
|
|
30
|
+
return _createClass(LocationManager, [{
|
|
31
|
+
key: "calculateAll",
|
|
32
|
+
value: function calculateAll() {
|
|
33
|
+
this.hasLocationList.length = 0;
|
|
34
|
+
this.hasLocationMap = {};
|
|
35
|
+
this.locationCount.length = 0;
|
|
36
|
+
this.startTime = _Browser.browser.now();
|
|
37
|
+
this.resizeFlag = false;
|
|
38
|
+
if (this.screenWidth !== (0, _App.getScreenWidth)() || this.screenHeight !== (0, _App.getScreenHeight)()) {
|
|
39
|
+
this.resizeFlag = true;
|
|
40
|
+
this.screenWidth = (0, _App.getScreenWidth)();
|
|
41
|
+
this.screenHeight = (0, _App.getScreenHeight)();
|
|
42
|
+
}
|
|
43
|
+
this.calculate();
|
|
44
|
+
}
|
|
45
|
+
}, {
|
|
46
|
+
key: "calculate",
|
|
47
|
+
value: function calculate() {
|
|
48
|
+
this.addToLocationList(_App.tApp.tRoot);
|
|
49
|
+
this.calculateContainer(_App.tApp.tRoot);
|
|
50
|
+
}
|
|
51
|
+
}, {
|
|
52
|
+
key: "getChildren",
|
|
53
|
+
value: function getChildren(container) {
|
|
54
|
+
if (this.isProlificContainer(container)) {
|
|
55
|
+
return _BracketGenerator.BracketGenerator.generate(container).list;
|
|
56
|
+
}
|
|
57
|
+
return container.getChildren();
|
|
58
|
+
}
|
|
59
|
+
}, {
|
|
60
|
+
key: "isProlificContainer",
|
|
61
|
+
value: function isProlificContainer(container) {
|
|
62
|
+
return container.canBeBracketed() && container.getChildren().length > this.bracketThreshold;
|
|
63
|
+
}
|
|
64
|
+
}, {
|
|
65
|
+
key: "calculateContainer",
|
|
66
|
+
value: function calculateContainer(container) {
|
|
67
|
+
var _this = this;
|
|
68
|
+
var allChildren = this.getChildren(container);
|
|
69
|
+
var viewport = container.createViewport();
|
|
70
|
+
container.inFlowVisibles.length = 0;
|
|
71
|
+
var i = 0;
|
|
72
|
+
var length = allChildren.length;
|
|
73
|
+
var _loop = function _loop() {
|
|
74
|
+
var child = allChildren[i++];
|
|
75
|
+
if (!child) {
|
|
76
|
+
return 1; // continue
|
|
77
|
+
}
|
|
78
|
+
var outerXEast;
|
|
79
|
+
var innerXEast;
|
|
80
|
+
var preX = child.domValues.x;
|
|
81
|
+
var preY = child.domValues.y;
|
|
82
|
+
_this.calculateTargets(child);
|
|
83
|
+
if (child.getActualValueLastUpdate('canBeBracketed') > child.getParent().getActualValueLastUpdate("allChildren")) {
|
|
84
|
+
delete child.getParent().targetValues['allChildren'];
|
|
85
|
+
}
|
|
86
|
+
viewport.setCurrentChild(child);
|
|
87
|
+
child.setLocation(viewport);
|
|
88
|
+
child.calculateAbsolutePosition(child.x, child.y);
|
|
89
|
+
innerXEast = _TUtil.TUtil.isDefined(container.val('innerXEast')) ? container.val('innerXEast') : container.getInnerXEast();
|
|
90
|
+
outerXEast = _TUtil.TUtil.isDefined(child.val('outerXEast')) ? child.val('outerXEast') : child.getOuterXEast();
|
|
91
|
+
if (viewport.isOverflow(outerXEast, innerXEast)) {
|
|
92
|
+
viewport.overflow();
|
|
93
|
+
child.setLocation(viewport);
|
|
94
|
+
} else {
|
|
95
|
+
child.setLocation(viewport);
|
|
96
|
+
}
|
|
97
|
+
if (child.isIncluded() && !_this.hasLocationMap[child.oid]) {
|
|
98
|
+
_this.addToLocationList(child);
|
|
99
|
+
}
|
|
100
|
+
if (child.isTargetEnabled('x') && !child.isTargetUpdating('x') && !child.isTargetImperative('x') && child.getTargetSteps('x') === 0) {
|
|
101
|
+
_TargetExecutor.TargetExecutor.resolveTargetValue(child, 'x');
|
|
102
|
+
_TargetExecutor.TargetExecutor.snapActualToTarget(child, 'x');
|
|
103
|
+
} else if (!_TUtil.TUtil.isDefined(child.targetValues.x)) {
|
|
104
|
+
child.val('x', child.x);
|
|
105
|
+
}
|
|
106
|
+
if (child.isTargetEnabled('y') && !child.isTargetUpdating('y') && !child.isTargetImperative('y') && child.getTargetSteps('y') === 0) {
|
|
107
|
+
_TargetExecutor.TargetExecutor.resolveTargetValue(child, 'y');
|
|
108
|
+
_TargetExecutor.TargetExecutor.snapActualToTarget(child, 'y');
|
|
109
|
+
} else if (!_TUtil.TUtil.isDefined(child.targetValues.y)) {
|
|
110
|
+
child.val('y', child.y);
|
|
111
|
+
}
|
|
112
|
+
if (preX !== child.getX() || preY !== child.getY()) {
|
|
113
|
+
child.addToStyleTargetList('transform');
|
|
114
|
+
}
|
|
115
|
+
child.calculateAbsolutePosition(child.getX(), child.getY());
|
|
116
|
+
viewport.isVisible(child);
|
|
117
|
+
child.addToParentVisibleList();
|
|
118
|
+
if (child.shouldCalculateChildren()) {
|
|
119
|
+
_this.calculateContainer(child);
|
|
120
|
+
}
|
|
121
|
+
if (child.isInFlow()) {
|
|
122
|
+
if (_TUtil.TUtil.isNumber(child.val('appendNewLine'))) {
|
|
123
|
+
viewport.appendNewLine();
|
|
124
|
+
viewport.calcContentWidthHeight();
|
|
125
|
+
} else {
|
|
126
|
+
viewport.calcContentWidthHeight();
|
|
127
|
+
viewport.nextLocation();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (Array.isArray(child.val('contentHeight'))) {
|
|
131
|
+
child.val('contentHeight').forEach(function (key) {
|
|
132
|
+
var preVal = child.val(key);
|
|
133
|
+
child.val(key, child.getContentHeight());
|
|
134
|
+
if (preVal !== child.val(key)) {
|
|
135
|
+
child.addToStyleTargetList(key);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
if (Array.isArray(child.val('contentWidth'))) {
|
|
140
|
+
child.val('contentWidth').forEach(function (key) {
|
|
141
|
+
var preVal = child.val(key);
|
|
142
|
+
child.val(key, child.getContentWidth());
|
|
143
|
+
if (preVal !== child.val(key)) {
|
|
144
|
+
child.addToStyleTargetList(key);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
viewport.calcContentWidthHeight();
|
|
149
|
+
_this.locationCount.push("".concat(child.oid, "-").concat(child.updatingTargetList.length, "-").concat(_Browser.browser.now() - _this.startTime));
|
|
150
|
+
};
|
|
151
|
+
while (i < length && _App.tApp.isRunning()) {
|
|
152
|
+
if (_loop()) continue;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}, {
|
|
156
|
+
key: "calculateTargets",
|
|
157
|
+
value: function calculateTargets(tmodel) {
|
|
158
|
+
this.activateTargetsOnEvents(tmodel);
|
|
159
|
+
_App.tApp.targetManager.applyTargetValues(tmodel);
|
|
160
|
+
_App.tApp.targetManager.setActualValues(tmodel);
|
|
161
|
+
if (tmodel.hasDom()) {
|
|
162
|
+
var preWidth = tmodel.getWidth();
|
|
163
|
+
var preHeight = tmodel.getHeight();
|
|
164
|
+
if (!_TUtil.TUtil.isDefined(tmodel.targetValues.width) && !_TUtil.TUtil.isDefined(tmodel.targets.width) && !_TUtil.TUtil.isDefined(tmodel.targetValues.contentWidth) || tmodel.getTargetValue('widthFromDom')) {
|
|
165
|
+
_TargetUtil.TargetUtil.setWidthFromDom(tmodel);
|
|
166
|
+
}
|
|
167
|
+
if (!_TUtil.TUtil.isDefined(tmodel.targetValues.height) && !_TUtil.TUtil.isDefined(tmodel.targets.height) && !_TUtil.TUtil.isDefined(tmodel.targetValues.contentHeight) || tmodel.getTargetValue('heightFromDom')) {
|
|
168
|
+
_TargetUtil.TargetUtil.setHeightFromDom(tmodel);
|
|
169
|
+
}
|
|
170
|
+
if (preWidth !== tmodel.getWidth() || preHeight !== tmodel.getHeight()) {
|
|
171
|
+
tmodel.addToStyleTargetList('dim');
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}, {
|
|
176
|
+
key: "activateTargetsOnEvents",
|
|
177
|
+
value: function activateTargetsOnEvents(tmodel) {
|
|
178
|
+
var activateTargets = [];
|
|
179
|
+
if (this.resizeFlag && tmodel.targets['onResize']) {
|
|
180
|
+
activateTargets = activateTargets.concat(tmodel.targets['onResize']);
|
|
181
|
+
}
|
|
182
|
+
if ((0, _App.getEvents)().isTouchHandler(tmodel) && tmodel.targets['onTouchEvent']) {
|
|
183
|
+
activateTargets = activateTargets.concat(tmodel.targets['onTouchEvent']);
|
|
184
|
+
}
|
|
185
|
+
if ((0, _App.getEvents)().isClickHandler(tmodel) && tmodel.targets['onClickEvent']) {
|
|
186
|
+
activateTargets = activateTargets.concat(tmodel.targets['onClickEvent']);
|
|
187
|
+
}
|
|
188
|
+
if ((0, _App.getEvents)().isScrollLeftHandler(tmodel) && (0, _App.getEvents)().deltaX() || (0, _App.getEvents)().isScrollTopHandler(tmodel) && (0, _App.getEvents)().deltaY()) {
|
|
189
|
+
if (tmodel.targets['onScrollEvent']) {
|
|
190
|
+
activateTargets = activateTargets.concat(tmodel.targets['onScrollEvent']);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if ((0, _App.getEvents)().currentKey && tmodel.targets['onKeyEvent']) {
|
|
194
|
+
activateTargets = activateTargets.concat(tmodel.targets['onKeyEvent']);
|
|
195
|
+
}
|
|
196
|
+
activateTargets.forEach(function (target) {
|
|
197
|
+
var key = _typeof(target) === 'object' ? target.key : target;
|
|
198
|
+
var obj = _typeof(target) === 'object' && target.tmodel ? target.tmodel : tmodel;
|
|
199
|
+
if (obj.targets[key] && (obj.isTargetComplete(key) || obj.getTargetStatus(key) === '')) {
|
|
200
|
+
obj.activateTarget(key);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}, {
|
|
205
|
+
key: "addToLocationList",
|
|
206
|
+
value: function addToLocationList(child) {
|
|
207
|
+
this.hasLocationList.push(child);
|
|
208
|
+
this.hasLocationMap[child.oid] = child;
|
|
209
|
+
}
|
|
210
|
+
}]);
|
|
211
|
+
}();
|
package/build/Moves.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Moves = void 0;
|
|
7
|
+
var _App = require("./App.js");
|
|
8
|
+
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); }
|
|
9
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
10
|
+
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); } }
|
|
11
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
12
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
13
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
14
|
+
var Moves = exports.Moves = /*#__PURE__*/function () {
|
|
15
|
+
function Moves() {
|
|
16
|
+
_classCallCheck(this, Moves);
|
|
17
|
+
}
|
|
18
|
+
return _createClass(Moves, null, [{
|
|
19
|
+
key: "bounce",
|
|
20
|
+
value: function bounce(from, to) {
|
|
21
|
+
var initialX = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : (0, _App.getScreenWidth)() / 2;
|
|
22
|
+
var initialWidth = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 50;
|
|
23
|
+
var initialHeight = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 50;
|
|
24
|
+
var bounceFactor = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0.6;
|
|
25
|
+
var compressionFactor = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 0.2;
|
|
26
|
+
var bounce = to * bounceFactor;
|
|
27
|
+
var ys = [from];
|
|
28
|
+
var xs = [initialX];
|
|
29
|
+
var widths = [initialWidth];
|
|
30
|
+
var heights = [initialHeight];
|
|
31
|
+
while ((bounce | 0) > 1) {
|
|
32
|
+
ys.push(to);
|
|
33
|
+
ys.push(to - bounce);
|
|
34
|
+
var compressedWidth = initialWidth * (1 + compressionFactor);
|
|
35
|
+
var compressedHeight = initialHeight * (1 - compressionFactor);
|
|
36
|
+
widths.push(compressedWidth);
|
|
37
|
+
widths.push(initialWidth);
|
|
38
|
+
heights.push(compressedHeight);
|
|
39
|
+
heights.push(initialHeight);
|
|
40
|
+
xs.push(initialX - (compressedWidth - initialWidth) / 2);
|
|
41
|
+
xs.push(initialX);
|
|
42
|
+
bounce *= bounceFactor;
|
|
43
|
+
compressionFactor *= bounceFactor;
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
x: xs,
|
|
47
|
+
y: ys,
|
|
48
|
+
width: widths,
|
|
49
|
+
height: heights
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}, {
|
|
53
|
+
key: "spiral",
|
|
54
|
+
value: function spiral(startAngle, endAngle, angleStep, x, y, width, height) {
|
|
55
|
+
var xCoords = [],
|
|
56
|
+
yCoords = [],
|
|
57
|
+
rotations = [];
|
|
58
|
+
for (var angle = startAngle; angle <= endAngle; angle += angleStep) {
|
|
59
|
+
var radians = angle * (Math.PI / 180);
|
|
60
|
+
xCoords.push(Math.floor(x + width * Math.cos(radians)));
|
|
61
|
+
yCoords.push(Math.floor(y + height * Math.sin(radians)));
|
|
62
|
+
rotations.push(90 + angle);
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
x: xCoords,
|
|
66
|
+
y: yCoords,
|
|
67
|
+
rotate: rotations
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}]);
|
|
71
|
+
}();
|