targetj 1.0.240 → 1.0.242
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/Export.js +27 -5
- package/README.md +108 -68
- package/build/$Dom.js +21 -25
- package/build/AnimationManager.js +40 -45
- package/build/AnimationUtil.js +41 -45
- package/build/App.js +73 -74
- package/build/BaseModel.js +86 -90
- package/build/Bracket.js +7 -21
- package/build/BracketGenerator.js +15 -19
- package/build/ColorUtil.js +3 -8
- package/build/DomInit.js +34 -38
- package/build/Easing.js +3 -8
- package/build/EventListener.js +66 -75
- package/build/LoadingManager.js +34 -38
- package/build/LocationManager.js +52 -56
- package/build/Moves.js +17 -21
- package/build/PageManager.js +64 -68
- package/build/RunScheduler.js +72 -73
- package/build/ScheduleUtil.js +20 -24
- package/build/SearchUtil.js +16 -20
- package/build/TModel.js +159 -99
- package/build/TModelManager.js +37 -41
- package/build/TModelUtil.js +122 -53
- package/build/TUtil.js +16 -20
- package/build/TargetData.js +40 -45
- package/build/TargetExecutor.js +72 -76
- package/build/TargetManager.js +49 -52
- package/build/TargetParser.js +35 -39
- package/build/TargetUtil.js +28 -31
- package/build/Viewport.js +24 -22
- package/build/VisibilityUtil.js +74 -70
- package/build/index.js +20 -225
- package/dist/targetjs.js +1 -1
- package/dist/targetjs.js.gz +0 -0
- package/package.json +1 -1
package/build/TargetManager.js
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.TargetManager = void 0;
|
|
7
|
-
var _TargetExecutor = require("./TargetExecutor.js");
|
|
8
|
-
var _App = require("./App.js");
|
|
9
|
-
var _TUtil = require("./TUtil.js");
|
|
10
|
-
var _TargetUtil = require("./TargetUtil.js");
|
|
11
|
-
var _TModelUtil = require("./TModelUtil.js");
|
|
12
|
-
var _SearchUtil = require("./SearchUtil.js");
|
|
13
|
-
var _ScheduleUtil = require("./ScheduleUtil.js");
|
|
14
|
-
var _AnimationUtil = require("./AnimationUtil.js");
|
|
15
1
|
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); }
|
|
16
2
|
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; } } }; }
|
|
17
3
|
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; } }
|
|
@@ -20,12 +6,22 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
|
|
|
20
6
|
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); } }
|
|
21
7
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
22
8
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
23
|
-
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); }
|
|
9
|
+
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); }
|
|
10
|
+
// TargetManager.js
|
|
11
|
+
import { TargetExecutor } from "./TargetExecutor.js";
|
|
12
|
+
import { getRunScheduler, getAnimationManager, getVisibles } from "./App.js";
|
|
13
|
+
import { TUtil } from "./TUtil.js";
|
|
14
|
+
import { TargetUtil } from "./TargetUtil.js";
|
|
15
|
+
import { TModelUtil } from "./TModelUtil.js";
|
|
16
|
+
import { SearchUtil } from "./SearchUtil.js";
|
|
17
|
+
import { ScheduleUtil } from "./ScheduleUtil.js";
|
|
18
|
+
import { AnimationUtil } from "./AnimationUtil.js";
|
|
19
|
+
|
|
24
20
|
/**
|
|
25
21
|
* Manages target execution/cycles and updates actual values toward target values.
|
|
26
22
|
* It also delegates animatable style targets to AnimationManager
|
|
27
23
|
*/
|
|
28
|
-
var TargetManager =
|
|
24
|
+
var TargetManager = /*#__PURE__*/function () {
|
|
29
25
|
function TargetManager() {
|
|
30
26
|
_classCallCheck(this, TargetManager);
|
|
31
27
|
}
|
|
@@ -52,11 +48,11 @@ var TargetManager = exports.TargetManager = /*#__PURE__*/function () {
|
|
|
52
48
|
key: "applyTargetValue",
|
|
53
49
|
value: function applyTargetValue(tmodel, key) {
|
|
54
50
|
var target = tmodel.targets[key];
|
|
55
|
-
if (!
|
|
51
|
+
if (!TUtil.isDefined(target)) {
|
|
56
52
|
tmodel.removeFromActiveTargets(key);
|
|
57
53
|
return;
|
|
58
54
|
}
|
|
59
|
-
if (
|
|
55
|
+
if (ScheduleUtil.shouldPauseTarget(tmodel, key)) {
|
|
60
56
|
return;
|
|
61
57
|
}
|
|
62
58
|
if (tmodel.isExecuted(key) && tmodel.hasUpdatingImperativeTargets(key)) {
|
|
@@ -66,9 +62,9 @@ var TargetManager = exports.TargetManager = /*#__PURE__*/function () {
|
|
|
66
62
|
if (tmodel.isScheduledPending(key)) {
|
|
67
63
|
return;
|
|
68
64
|
}
|
|
69
|
-
var schedulePeriod =
|
|
65
|
+
var schedulePeriod = ScheduleUtil.scheduleExecution(tmodel, key);
|
|
70
66
|
if (schedulePeriod > 0) {
|
|
71
|
-
|
|
67
|
+
getRunScheduler().schedule(schedulePeriod, "targetSchedule__".concat(tmodel.oid));
|
|
72
68
|
return;
|
|
73
69
|
}
|
|
74
70
|
}
|
|
@@ -79,10 +75,10 @@ var TargetManager = exports.TargetManager = /*#__PURE__*/function () {
|
|
|
79
75
|
return;
|
|
80
76
|
}
|
|
81
77
|
tmodel.resetScheduleTimeStamp(key);
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (!
|
|
85
|
-
|
|
78
|
+
TargetExecutor.prepareTarget(tmodel, key);
|
|
79
|
+
TargetExecutor.executeDeclarativeTarget(tmodel, key);
|
|
80
|
+
if (!TUtil.isDefined(target.fetchAction)) {
|
|
81
|
+
TargetUtil.shouldActivateNextTarget(tmodel, key);
|
|
86
82
|
}
|
|
87
83
|
}
|
|
88
84
|
}, {
|
|
@@ -98,12 +94,12 @@ var TargetManager = exports.TargetManager = /*#__PURE__*/function () {
|
|
|
98
94
|
try {
|
|
99
95
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
100
96
|
var key = _step2.value;
|
|
101
|
-
if (
|
|
97
|
+
if (ScheduleUtil.shouldPauseTarget(tmodel, key)) {
|
|
102
98
|
continue;
|
|
103
99
|
}
|
|
104
|
-
schedulePeriod =
|
|
100
|
+
schedulePeriod = ScheduleUtil.scheduleExecution(tmodel, key);
|
|
105
101
|
if (schedulePeriod > 0) {
|
|
106
|
-
|
|
102
|
+
getRunScheduler().schedule(schedulePeriod, "setActualValues-".concat(tmodel.oid));
|
|
107
103
|
} else {
|
|
108
104
|
tmodel.resetScheduleTimeStamp(key);
|
|
109
105
|
this.setActualValue(tmodel, key);
|
|
@@ -119,13 +115,13 @@ var TargetManager = exports.TargetManager = /*#__PURE__*/function () {
|
|
|
119
115
|
tmodel.waapiBatch = undefined;
|
|
120
116
|
return;
|
|
121
117
|
}
|
|
122
|
-
|
|
118
|
+
getAnimationManager().animate(tmodel, batch, AnimationUtil.getAnimationHooks());
|
|
123
119
|
tmodel.waapiBatch = undefined;
|
|
124
120
|
}
|
|
125
121
|
}, {
|
|
126
122
|
key: "findOriginalTModel",
|
|
127
123
|
value: function findOriginalTModel(tmodel, originalTargetName) {
|
|
128
|
-
return
|
|
124
|
+
return SearchUtil.findParentByTarget(tmodel, originalTargetName) || getVisibles().find(function (tmodel) {
|
|
129
125
|
return tmodel.targets[originalTargetName];
|
|
130
126
|
});
|
|
131
127
|
}
|
|
@@ -149,7 +145,7 @@ var TargetManager = exports.TargetManager = /*#__PURE__*/function () {
|
|
|
149
145
|
var needsRefire = false;
|
|
150
146
|
if (tmodel.isTargetImperative(key)) {
|
|
151
147
|
if (originalTarget) {
|
|
152
|
-
var capKey =
|
|
148
|
+
var capKey = TargetUtil.getTargetName(TUtil.capitalizeFirstLetter(key));
|
|
153
149
|
if (typeof originalTarget["on".concat(capKey, "Step")] === 'function') {
|
|
154
150
|
originalTarget["on".concat(capKey, "Step")].call(originalTModel, originalTModel.val(key), theValue, step, steps);
|
|
155
151
|
originalTModel.setTargetMethodName(originalTargetName, ["on".concat(capKey, "Step")]);
|
|
@@ -161,14 +157,14 @@ var TargetManager = exports.TargetManager = /*#__PURE__*/function () {
|
|
|
161
157
|
}
|
|
162
158
|
if (originalTarget.activateNextTarget && !originalTarget.activateNextTarget.endsWith('$$') && originalTarget.activateNextTarget.endsWith('$')) {
|
|
163
159
|
needsRefire = true;
|
|
164
|
-
|
|
160
|
+
TargetUtil.shouldActivateNextTarget(tmodel, key);
|
|
165
161
|
}
|
|
166
162
|
}
|
|
167
163
|
} else {
|
|
168
|
-
needsRefire =
|
|
164
|
+
needsRefire = TUtil.handleValueChange(tmodel, key);
|
|
169
165
|
if (target !== null && target !== void 0 && target.activateNextTarget && !target.activateNextTarget.endsWith('$$') && target.activateNextTarget.endsWith('$')) {
|
|
170
166
|
needsRefire = true;
|
|
171
|
-
|
|
167
|
+
TargetUtil.shouldActivateNextTarget(tmodel, key);
|
|
172
168
|
}
|
|
173
169
|
}
|
|
174
170
|
return needsRefire;
|
|
@@ -193,7 +189,7 @@ var TargetManager = exports.TargetManager = /*#__PURE__*/function () {
|
|
|
193
189
|
var newStatus = this.calculateTargetStatus(tmodel, key);
|
|
194
190
|
tmodel.setTargetStatus(key, newStatus);
|
|
195
191
|
if (tmodel.isTargetImperative(key)) {
|
|
196
|
-
var capKey =
|
|
192
|
+
var capKey = TargetUtil.getTargetName(TUtil.capitalizeFirstLetter(key));
|
|
197
193
|
if (originalTarget && typeof originalTarget["on".concat(capKey, "End")] === "function") {
|
|
198
194
|
originalTarget["on".concat(capKey, "End")].call(originalTModel, originalTModel.val(key), theValue, steps, steps);
|
|
199
195
|
originalTModel.setTargetMethodName(originalTargetName, ["on".concat(capKey, "End")]);
|
|
@@ -215,14 +211,14 @@ var TargetManager = exports.TargetManager = /*#__PURE__*/function () {
|
|
|
215
211
|
tmodel.resetTargetInitialValue(key);
|
|
216
212
|
tmodel.resetTargetExecutionFlag(key);
|
|
217
213
|
delete targetValue.valuePointer;
|
|
218
|
-
|
|
214
|
+
TargetExecutor.executeDeclarativeTarget(tmodel, key);
|
|
219
215
|
}
|
|
220
216
|
if (typeof ((_tmodel$targets$key = tmodel.targets[key]) === null || _tmodel$targets$key === void 0 ? void 0 : _tmodel$targets$key.onStepsEnd) === "function") {
|
|
221
217
|
tmodel.targets[key].onStepsEnd.call(tmodel, tmodel.getTargetCycle(key));
|
|
222
218
|
tmodel.setTargetMethodName(key, "onStepsEnd");
|
|
223
219
|
}
|
|
224
220
|
}
|
|
225
|
-
|
|
221
|
+
TargetUtil.shouldActivateNextTarget(tmodel, key);
|
|
226
222
|
}
|
|
227
223
|
}, {
|
|
228
224
|
key: "calculateTargetStatus",
|
|
@@ -256,7 +252,7 @@ var TargetManager = exports.TargetManager = /*#__PURE__*/function () {
|
|
|
256
252
|
done: false
|
|
257
253
|
};
|
|
258
254
|
}
|
|
259
|
-
var progress =
|
|
255
|
+
var progress = TUtil.advanceTargetByElapsed(tmodel, key);
|
|
260
256
|
var step = progress.step;
|
|
261
257
|
var valuePointer = progress.valuePointer;
|
|
262
258
|
var cycle = progress.cycle;
|
|
@@ -285,11 +281,11 @@ var TargetManager = exports.TargetManager = /*#__PURE__*/function () {
|
|
|
285
281
|
};
|
|
286
282
|
}
|
|
287
283
|
var initialValue = tmodel.getTargetInitialValue(key);
|
|
288
|
-
if (!
|
|
284
|
+
if (!TUtil.isDefined(initialValue)) {
|
|
289
285
|
initialValue = this.resolveInitialValue(tmodel, key, theValue);
|
|
290
286
|
tmodel.setTargetInitialValue(key, initialValue);
|
|
291
287
|
}
|
|
292
|
-
var value = step > 0 ?
|
|
288
|
+
var value = step > 0 ? TModelUtil.easingMorph(tmodel, key, initialValue, theValue, step, steps) : initialValue;
|
|
293
289
|
tmodel.val(key, value);
|
|
294
290
|
tmodel.setActual(key, value);
|
|
295
291
|
tmodel.addToStyleTargetList(key);
|
|
@@ -315,7 +311,7 @@ var TargetManager = exports.TargetManager = /*#__PURE__*/function () {
|
|
|
315
311
|
return;
|
|
316
312
|
}
|
|
317
313
|
var state = this.getTargetUpdateState(tmodel, key);
|
|
318
|
-
if (!
|
|
314
|
+
if (!TUtil.isDefined(state.initialValue)) {
|
|
319
315
|
state.initialValue = this.resolveInitialValue(tmodel, key, state.theValue);
|
|
320
316
|
tmodel.setTargetInitialValue(key, state.initialValue);
|
|
321
317
|
}
|
|
@@ -323,7 +319,7 @@ var TargetManager = exports.TargetManager = /*#__PURE__*/function () {
|
|
|
323
319
|
fireEnd: true
|
|
324
320
|
});
|
|
325
321
|
if (catchup.done) {
|
|
326
|
-
|
|
322
|
+
getRunScheduler().scheduleOnlyIfEarlier(1, "".concat(tmodel.oid, "---").concat(key, "-catchup-finished"));
|
|
327
323
|
return;
|
|
328
324
|
}
|
|
329
325
|
var step = (_catchup$step = catchup.step) !== null && _catchup$step !== void 0 ? _catchup$step : 0;
|
|
@@ -338,7 +334,7 @@ var TargetManager = exports.TargetManager = /*#__PURE__*/function () {
|
|
|
338
334
|
key: "canUpdateTarget",
|
|
339
335
|
value: function canUpdateTarget(tmodel, key) {
|
|
340
336
|
if (!tmodel.isTargetImperative(key) && !tmodel.isTargetEnabled(key)) {
|
|
341
|
-
|
|
337
|
+
getRunScheduler().schedule(15, "setActualValue-postpone-".concat(tmodel.oid));
|
|
342
338
|
return false;
|
|
343
339
|
}
|
|
344
340
|
return true;
|
|
@@ -348,19 +344,19 @@ var TargetManager = exports.TargetManager = /*#__PURE__*/function () {
|
|
|
348
344
|
value: function getTargetUpdateState(tmodel, key) {
|
|
349
345
|
return {
|
|
350
346
|
theValue: tmodel.getTargetValue(key),
|
|
351
|
-
cleanKey:
|
|
347
|
+
cleanKey: TargetUtil.getTargetName(key),
|
|
352
348
|
steps: tmodel.getTargetSteps(key),
|
|
353
349
|
cycle: tmodel.getTargetCycle(key),
|
|
354
350
|
interval: tmodel.getTargetInterval(key),
|
|
355
351
|
initialValue: tmodel.getTargetInitialValue(key),
|
|
356
352
|
lastUpdateTime: tmodel.getLastUpdate(key),
|
|
357
|
-
now:
|
|
353
|
+
now: TUtil.now()
|
|
358
354
|
};
|
|
359
355
|
}
|
|
360
356
|
}, {
|
|
361
357
|
key: "resolveInitialValue",
|
|
362
358
|
value: function resolveInitialValue(tmodel, key, theValue) {
|
|
363
|
-
if (
|
|
359
|
+
if (TUtil.isDefined(tmodel.val(key))) {
|
|
364
360
|
return tmodel.val(key);
|
|
365
361
|
}
|
|
366
362
|
if (typeof theValue === 'number') {
|
|
@@ -374,11 +370,11 @@ var TargetManager = exports.TargetManager = /*#__PURE__*/function () {
|
|
|
374
370
|
if (!tmodel.hasDom()) {
|
|
375
371
|
return;
|
|
376
372
|
}
|
|
377
|
-
var newValue = step > 0 ?
|
|
373
|
+
var newValue = step > 0 ? TModelUtil.easingMorph(tmodel, key, state.initialValue, state.theValue, step, state.steps) : state.initialValue;
|
|
378
374
|
var cycles = tmodel.isTargetImperative(key) ? tmodel.getTargetCycles(key) : 0;
|
|
379
|
-
var cycleDuration =
|
|
375
|
+
var cycleDuration = AnimationUtil.handleWebAnimationAPI(tmodel, state.cleanKey, key, targetValue, newValue, state.theValue, valuePointer, step, state.steps, state.interval, 0, false, true);
|
|
380
376
|
for (var c = 1; c < cycles; c++) {
|
|
381
|
-
|
|
377
|
+
AnimationUtil.handleWebAnimationAPI(tmodel, state.cleanKey, key, targetValue, newValue, state.theValue, valuePointer, step, state.steps, state.interval, c * cycleDuration, true, false);
|
|
382
378
|
}
|
|
383
379
|
}
|
|
384
380
|
}, {
|
|
@@ -386,13 +382,13 @@ var TargetManager = exports.TargetManager = /*#__PURE__*/function () {
|
|
|
386
382
|
value: function updateActualValue(tmodel, key, targetValue, state, step, valuePointer) {
|
|
387
383
|
if (step <= state.steps) {
|
|
388
384
|
tmodel.incrementTargetStep(key, state.now, state.lastUpdateTime, state.interval, state.steps);
|
|
389
|
-
var newValue =
|
|
385
|
+
var newValue = TModelUtil.easingMorph(tmodel, key, state.initialValue, state.theValue, step, state.steps);
|
|
390
386
|
tmodel.val(key, newValue);
|
|
391
387
|
tmodel.setActual(key, newValue);
|
|
392
388
|
tmodel.addToStyleTargetList(key);
|
|
393
389
|
this.fireOnStep(tmodel, key, step);
|
|
394
390
|
if (tmodel.getTargetStep(key) < state.steps) {
|
|
395
|
-
|
|
391
|
+
getRunScheduler().scheduleOnlyIfEarlier(state.interval, "".concat(tmodel.oid, "---").concat(key, "-").concat(step, "/").concat(state.steps, "-").concat(state.cycle, "-").concat(state.interval));
|
|
396
392
|
return;
|
|
397
393
|
}
|
|
398
394
|
}
|
|
@@ -420,7 +416,8 @@ var TargetManager = exports.TargetManager = /*#__PURE__*/function () {
|
|
|
420
416
|
} else {
|
|
421
417
|
this.fireOnEnd(tmodel, key);
|
|
422
418
|
}
|
|
423
|
-
|
|
419
|
+
getRunScheduler().scheduleOnlyIfEarlier(scheduleTime, "".concat(tmodel.oid, "---").concat(key, "-").concat(state.steps, "/").concat(state.steps, "-").concat(state.cycle, "-").concat(scheduleTime));
|
|
424
420
|
}
|
|
425
421
|
}]);
|
|
426
|
-
}();
|
|
422
|
+
}();
|
|
423
|
+
export { TargetManager };
|
package/build/TargetParser.js
CHANGED
|
@@ -1,24 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.TargetParser = void 0;
|
|
7
|
-
var _TargetUtil = require("./TargetUtil.js");
|
|
8
|
-
var _TargetData = require("./TargetData.js");
|
|
9
|
-
var _TUtil = require("./TUtil.js");
|
|
10
|
-
var _TModel = require("./TModel.js");
|
|
11
|
-
var _Easing = require("./Easing.js");
|
|
12
1
|
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); }
|
|
13
2
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
14
3
|
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
4
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
16
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
17
6
|
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); }
|
|
7
|
+
import { TargetUtil } from "./TargetUtil.js";
|
|
8
|
+
import { TargetData } from './TargetData.js';
|
|
9
|
+
import { TUtil } from './TUtil.js';
|
|
10
|
+
import { TModel } from "./TModel.js";
|
|
11
|
+
import { Easing } from "./Easing.js";
|
|
12
|
+
|
|
18
13
|
/**
|
|
19
14
|
* It provides helper functions for classify target types
|
|
20
15
|
*/
|
|
21
|
-
var TargetParser =
|
|
16
|
+
var TargetParser = /*#__PURE__*/function () {
|
|
22
17
|
function TargetParser() {
|
|
23
18
|
_classCallCheck(this, TargetParser);
|
|
24
19
|
}
|
|
@@ -32,7 +27,7 @@ var TargetParser = exports.TargetParser = /*#__PURE__*/function () {
|
|
|
32
27
|
value: function hasLifecycle(object) {
|
|
33
28
|
for (var key in object) {
|
|
34
29
|
var value = object[key];
|
|
35
|
-
if (typeof value === 'function' &&
|
|
30
|
+
if (typeof value === 'function' && TargetData.isLifeCycleMethod(key)) {
|
|
36
31
|
return true;
|
|
37
32
|
}
|
|
38
33
|
}
|
|
@@ -46,8 +41,8 @@ var TargetParser = exports.TargetParser = /*#__PURE__*/function () {
|
|
|
46
41
|
}, {
|
|
47
42
|
key: "isTargetKey",
|
|
48
43
|
value: function isTargetKey(key) {
|
|
49
|
-
key =
|
|
50
|
-
return
|
|
44
|
+
key = TargetUtil.getTargetName(key);
|
|
45
|
+
return TargetData.reservedKeywordSet.has(key);
|
|
51
46
|
}
|
|
52
47
|
}, {
|
|
53
48
|
key: "scoreChild",
|
|
@@ -56,7 +51,7 @@ var TargetParser = exports.TargetParser = /*#__PURE__*/function () {
|
|
|
56
51
|
var t = 0;
|
|
57
52
|
for (var key in targetValue) {
|
|
58
53
|
var value = targetValue[key];
|
|
59
|
-
if (
|
|
54
|
+
if (TargetData.defaultTargetStyles[key] || TargetData.excludedTargetKeys.has(key) || key === 'active') {
|
|
60
55
|
continue;
|
|
61
56
|
}
|
|
62
57
|
if (TargetParser.hasTargetSuffix(key)) {
|
|
@@ -65,7 +60,7 @@ var TargetParser = exports.TargetParser = /*#__PURE__*/function () {
|
|
|
65
60
|
return true;
|
|
66
61
|
} else if (TargetParser.isTargetKey(key)) {
|
|
67
62
|
c++;
|
|
68
|
-
} else if (!
|
|
63
|
+
} else if (!TargetData.activationKeywordSet.has(key) && !(typeof targetValue[key] === 'function')) {
|
|
69
64
|
t++;
|
|
70
65
|
}
|
|
71
66
|
}
|
|
@@ -83,7 +78,7 @@ var TargetParser = exports.TargetParser = /*#__PURE__*/function () {
|
|
|
83
78
|
if (key === 'originalTModel') {
|
|
84
79
|
return 'target3';
|
|
85
80
|
}
|
|
86
|
-
if (value instanceof
|
|
81
|
+
if (value instanceof TModel) {
|
|
87
82
|
return 'children';
|
|
88
83
|
}
|
|
89
84
|
if (TargetParser.isListTarget(value) || TargetParser.isFetchTarget(key, value) || TargetParser.isFetchImageTarget(key, value)) {
|
|
@@ -108,12 +103,12 @@ var TargetParser = exports.TargetParser = /*#__PURE__*/function () {
|
|
|
108
103
|
}, {
|
|
109
104
|
key: "isChildrenTarget",
|
|
110
105
|
value: function isChildrenTarget(key, value) {
|
|
111
|
-
return (
|
|
106
|
+
return (TargetUtil.getTargetName(key) === 'children' || TargetUtil.getTargetName(key) === 'addChildren') && _typeof(value) === 'object';
|
|
112
107
|
}
|
|
113
108
|
}, {
|
|
114
109
|
key: "isChildTarget",
|
|
115
110
|
value: function isChildTarget(key, value) {
|
|
116
|
-
return
|
|
111
|
+
return TargetUtil.getTargetName(key) === 'child' && _typeof(value) === 'object';
|
|
117
112
|
}
|
|
118
113
|
}, {
|
|
119
114
|
key: "isChildObjectTarget",
|
|
@@ -131,7 +126,7 @@ var TargetParser = exports.TargetParser = /*#__PURE__*/function () {
|
|
|
131
126
|
}, {
|
|
132
127
|
key: "isFetchTarget",
|
|
133
128
|
value: function isFetchTarget(key, value) {
|
|
134
|
-
if (
|
|
129
|
+
if (TargetUtil.getTargetName(key) !== 'fetch') {
|
|
135
130
|
return false;
|
|
136
131
|
}
|
|
137
132
|
if (typeof value === 'string' || Array.isArray(value)) {
|
|
@@ -145,12 +140,12 @@ var TargetParser = exports.TargetParser = /*#__PURE__*/function () {
|
|
|
145
140
|
}, {
|
|
146
141
|
key: "isFetchImageTarget",
|
|
147
142
|
value: function isFetchImageTarget(key, value) {
|
|
148
|
-
return
|
|
143
|
+
return TargetUtil.getTargetName(key) === 'fetchImage' && value && (typeof value === 'string' || Array.isArray(value));
|
|
149
144
|
}
|
|
150
145
|
}, {
|
|
151
146
|
key: "isObjectTarget",
|
|
152
147
|
value: function isObjectTarget(key, value) {
|
|
153
|
-
return
|
|
148
|
+
return TargetUtil.getTargetName(key) !== 'style' && _typeof(value) === 'object' && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype && !TargetParser.isTargetSpecObject(value);
|
|
154
149
|
}
|
|
155
150
|
}, {
|
|
156
151
|
key: "isIntervalTarget",
|
|
@@ -158,10 +153,10 @@ var TargetParser = exports.TargetParser = /*#__PURE__*/function () {
|
|
|
158
153
|
if (!target || _typeof(target) !== 'object') {
|
|
159
154
|
return false;
|
|
160
155
|
}
|
|
161
|
-
if (target.isInterval &&
|
|
156
|
+
if (target.isInterval && TUtil.isDefined(target.interval)) {
|
|
162
157
|
return true;
|
|
163
158
|
}
|
|
164
|
-
return
|
|
159
|
+
return TUtil.isDefined(target.interval) && !TUtil.isDefined(target.loop) && !TUtil.isDefined(target.steps) && !TUtil.isDefined(target.cycles);
|
|
165
160
|
}
|
|
166
161
|
}, {
|
|
167
162
|
key: "isPrimitiveArray",
|
|
@@ -196,7 +191,7 @@ var TargetParser = exports.TargetParser = /*#__PURE__*/function () {
|
|
|
196
191
|
if (arr.length >= 4) {
|
|
197
192
|
var v3 = arr[3];
|
|
198
193
|
var isCycles = typeof v3 === "number";
|
|
199
|
-
var isEasing = typeof v3 === "string" &&
|
|
194
|
+
var isEasing = typeof v3 === "string" && Easing.easeMap.has(v3);
|
|
200
195
|
if (!isCycles && !isEasing) {
|
|
201
196
|
return false;
|
|
202
197
|
}
|
|
@@ -206,7 +201,7 @@ var TargetParser = exports.TargetParser = /*#__PURE__*/function () {
|
|
|
206
201
|
if (arr.length === 5) {
|
|
207
202
|
var _v = arr[3];
|
|
208
203
|
var v4 = arr[4];
|
|
209
|
-
if (!(typeof _v === "string" &&
|
|
204
|
+
if (!(typeof _v === "string" && Easing.easeMap.has(_v))) {
|
|
210
205
|
return false;
|
|
211
206
|
}
|
|
212
207
|
if (typeof v4 !== "number") {
|
|
@@ -261,25 +256,25 @@ var TargetParser = exports.TargetParser = /*#__PURE__*/function () {
|
|
|
261
256
|
|
|
262
257
|
// Plain objects: compute value + params (steps/interval/easing/cycles)
|
|
263
258
|
if (_typeof(target) === "object" && target !== null && Object.getPrototypeOf(target) === Object.prototype) {
|
|
264
|
-
var valueResult =
|
|
265
|
-
if (TargetParser.isPrimitiveArray(valueResult) && (
|
|
259
|
+
var valueResult = TUtil.runTargetValue(tmodel, target, key, cycle, lastValue);
|
|
260
|
+
if (TargetParser.isPrimitiveArray(valueResult) && (TUtil.isDefined(target.steps) || TUtil.isDefined(target.interval) || TUtil.isDefined(target.easing) || TUtil.isDefined(target.cycles))) {
|
|
266
261
|
value = {
|
|
267
262
|
list: valueResult
|
|
268
263
|
};
|
|
269
|
-
steps =
|
|
270
|
-
interval =
|
|
271
|
-
easing =
|
|
272
|
-
cycles =
|
|
264
|
+
steps = TUtil.isDefined(target.steps) ? resolveMaybeFn(target.steps, cycle) : 0;
|
|
265
|
+
interval = TUtil.isDefined(target.interval) ? resolveMaybeFn(target.interval, cycle) : 8;
|
|
266
|
+
easing = TUtil.isDefined(target.easing) ? resolveMaybeFn(target.easing, cycle) : easing;
|
|
267
|
+
cycles = TUtil.isDefined(target.cycles) ? resolveMaybeFn(target.cycles, cycle, tmodel.getTargetCycles(key)) : 1;
|
|
273
268
|
return [value, steps, interval, easing, cycles];
|
|
274
|
-
} else if (_typeof(valueResult) === 'object' &&
|
|
269
|
+
} else if (_typeof(valueResult) === 'object' && TUtil.isDefined(valueResult.value) && TUtil.isDefined(valueResult.steps)) {
|
|
275
270
|
return getValue(valueResult);
|
|
276
271
|
}
|
|
277
272
|
value = valueResult;
|
|
278
|
-
steps =
|
|
279
|
-
interval =
|
|
280
|
-
easing =
|
|
273
|
+
steps = TUtil.isDefined(target.steps) ? resolveMaybeFn(target.steps, cycle) : 0;
|
|
274
|
+
interval = TUtil.isDefined(target.interval) ? resolveMaybeFn(target.interval, cycle) : 0;
|
|
275
|
+
easing = TUtil.isDefined(target.easing) ? resolveMaybeFn(target.easing, cycle) : easing; // keep prior easing if not supplied
|
|
281
276
|
|
|
282
|
-
cycles =
|
|
277
|
+
cycles = TUtil.isDefined(target.cycles) ? resolveMaybeFn(target.cycles, cycle, tmodel.getTargetCycles(key)) : 1;
|
|
283
278
|
return Array.isArray(value) ? getValue(value) : [value, steps, interval, easing, cycles];
|
|
284
279
|
}
|
|
285
280
|
|
|
@@ -294,4 +289,5 @@ var TargetParser = exports.TargetParser = /*#__PURE__*/function () {
|
|
|
294
289
|
return getValue(_target);
|
|
295
290
|
}
|
|
296
291
|
}]);
|
|
297
|
-
}();
|
|
292
|
+
}();
|
|
293
|
+
export { TargetParser };
|