targetj 1.0.259 → 1.1.0
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 +16 -1
- package/README.md +18 -25
- package/build/AnimationManager.js +1 -1
- package/build/AnimationUtil.js +1 -8
- package/build/App.js +13 -4
- package/build/BaseModel.js +39 -14
- package/build/Bracket.js +7 -1
- package/build/Child.js +504 -0
- package/build/EventListener.js +10 -1
- package/build/LocationManager.js +161 -40
- package/build/PageManager.js +35 -134
- package/build/ParticleChild.js +575 -0
- package/build/ParticleRenderer.js +818 -0
- package/build/ParticleRuntime.js +1513 -0
- package/build/ParticleTModel.js +1423 -0
- package/build/ParticleUtil.js +265 -0
- package/build/RunScheduler.js +10 -3
- package/build/ScheduleUtil.js +2 -2
- package/build/StateManager.js +235 -31
- package/build/StateUtil.js +14 -15
- package/build/TModel.js +62 -28
- package/build/TModelFactory.js +48 -0
- package/build/TModelManager.js +146 -98
- package/build/TModelUtil.js +11 -8
- package/build/TUtil.js +57 -47
- package/build/TargetData.js +7 -1
- package/build/TargetExecutor.js +63 -9
- package/build/TargetManager.js +39 -23
- package/build/TargetParser.js +38 -2
- package/build/TargetUtil.js +26 -5
- package/build/Viewport.js +2 -2
- package/build/VisibilityUtil.js +4 -2
- package/build/index.js +6 -1
- package/dist/targetjs.js +1 -1
- package/dist/targetjs.js.gz +0 -0
- package/package.json +1 -1
|
@@ -0,0 +1,265 @@
|
|
|
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); }
|
|
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; } } }; }
|
|
3
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
4
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
+
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; } }
|
|
6
|
+
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; }
|
|
7
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
8
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
9
|
+
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; }
|
|
10
|
+
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; }
|
|
11
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
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); } }
|
|
13
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
14
|
+
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; }
|
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
16
|
+
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); }
|
|
17
|
+
import { TargetParser } from "./TargetParser.js";
|
|
18
|
+
import { TargetUtil } from "./TargetUtil.js";
|
|
19
|
+
import { TUtil } from "./TUtil.js";
|
|
20
|
+
var ParticleUtil = /*#__PURE__*/function () {
|
|
21
|
+
function ParticleUtil() {
|
|
22
|
+
_classCallCheck(this, ParticleUtil);
|
|
23
|
+
}
|
|
24
|
+
return _createClass(ParticleUtil, null, [{
|
|
25
|
+
key: "affectsChildLayout",
|
|
26
|
+
value: function affectsChildLayout(key) {
|
|
27
|
+
return ["x", "y", "width", "height"].includes(ParticleUtil.getTargetName(key));
|
|
28
|
+
}
|
|
29
|
+
}, {
|
|
30
|
+
key: "affectsChildFlowLayout",
|
|
31
|
+
value: function affectsChildFlowLayout(key) {
|
|
32
|
+
return ["width", "height"].includes(ParticleUtil.getTargetName(key));
|
|
33
|
+
}
|
|
34
|
+
}, {
|
|
35
|
+
key: "isChildrenTarget",
|
|
36
|
+
value: function isChildrenTarget(key) {
|
|
37
|
+
return ParticleUtil.childrenTargets.has(TargetUtil.getTargetName(key));
|
|
38
|
+
}
|
|
39
|
+
}, {
|
|
40
|
+
key: "getTargetName",
|
|
41
|
+
value: function getTargetName(key) {
|
|
42
|
+
var cleanKey = TargetUtil.getTargetName(key);
|
|
43
|
+
return ParticleUtil.gpuRenderAliases[cleanKey] || cleanKey;
|
|
44
|
+
}
|
|
45
|
+
}, {
|
|
46
|
+
key: "isGpuTarget",
|
|
47
|
+
value: function isGpuTarget(key) {
|
|
48
|
+
return ParticleUtil.gpuRenderTargets.has(ParticleUtil.getTargetName(key));
|
|
49
|
+
}
|
|
50
|
+
}, {
|
|
51
|
+
key: "getTargetMode",
|
|
52
|
+
value: function getTargetMode(key) {
|
|
53
|
+
if (key.endsWith("$$")) {
|
|
54
|
+
return "deferred";
|
|
55
|
+
}
|
|
56
|
+
if (key.endsWith("$")) {
|
|
57
|
+
return "reactive";
|
|
58
|
+
}
|
|
59
|
+
return "immediate";
|
|
60
|
+
}
|
|
61
|
+
}, {
|
|
62
|
+
key: "isTransientRuntimeField",
|
|
63
|
+
value: function isTransientRuntimeField(key) {
|
|
64
|
+
return ParticleUtil.transientRuntimeFields.has(key);
|
|
65
|
+
}
|
|
66
|
+
}, {
|
|
67
|
+
key: "isFunctionBasedTarget",
|
|
68
|
+
value: function isFunctionBasedTarget(target) {
|
|
69
|
+
if (typeof target === "function") {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
return TargetParser.isTargetSpecObject(target) && typeof target.value === "function";
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
75
|
+
key: "resolveValue",
|
|
76
|
+
value: function resolveValue(target, child) {
|
|
77
|
+
if (typeof target === "function") {
|
|
78
|
+
return ParticleUtil.resolveValue(target.call(child), child);
|
|
79
|
+
}
|
|
80
|
+
if (!TargetParser.isTargetSpecObject(target)) {
|
|
81
|
+
return target;
|
|
82
|
+
}
|
|
83
|
+
var resolved = _objectSpread({}, target);
|
|
84
|
+
if (typeof resolved.value === "function") {
|
|
85
|
+
resolved.value = ParticleUtil.resolveValue(resolved.value.call(child), child);
|
|
86
|
+
}
|
|
87
|
+
return resolved;
|
|
88
|
+
}
|
|
89
|
+
}, {
|
|
90
|
+
key: "getInitialValue",
|
|
91
|
+
value: function getInitialValue(value) {
|
|
92
|
+
if (TargetParser.isValueStepsCycleArray(value)) {
|
|
93
|
+
return value[0];
|
|
94
|
+
}
|
|
95
|
+
if (!TargetParser.isTargetSpecObject(value)) {
|
|
96
|
+
return value;
|
|
97
|
+
}
|
|
98
|
+
if (Array.isArray(value.value)) {
|
|
99
|
+
return value.value[0];
|
|
100
|
+
}
|
|
101
|
+
return value.value;
|
|
102
|
+
}
|
|
103
|
+
}, {
|
|
104
|
+
key: "setInitialValue",
|
|
105
|
+
value: function setInitialValue(child, key, value) {
|
|
106
|
+
if (!child || !TUtil.isDefined(value)) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
child.val(key, value);
|
|
110
|
+
}
|
|
111
|
+
}, {
|
|
112
|
+
key: "requiresRuntime",
|
|
113
|
+
value: function requiresRuntime(key, target) {
|
|
114
|
+
var mode = ParticleUtil.getTargetMode(key);
|
|
115
|
+
if (!ParticleUtil.isGpuTarget(key) || TargetParser.isIntervalTarget(target)) {
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
if (mode !== "immediate") {
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
if (TargetParser.isValueStepsCycleArray(target)) {
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
if (!TargetParser.isTargetSpecObject(target)) {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
return typeof target.value === "function" || typeof target.steps === "function" || TUtil.isDefined(target.interval) || TUtil.isDefined(target.easing) || TUtil.isDefined(target.cycles) || TUtil.isDefined(target.loop) || TUtil.isDefined(target.pauseOn);
|
|
128
|
+
}
|
|
129
|
+
}, {
|
|
130
|
+
key: "compileChildDefinition",
|
|
131
|
+
value: function compileChildDefinition(child, definition) {
|
|
132
|
+
var renderDefinition = {};
|
|
133
|
+
var runtimeTargets = [];
|
|
134
|
+
var entries = Object.entries(definition).map(function (_ref) {
|
|
135
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
136
|
+
key = _ref2[0],
|
|
137
|
+
target = _ref2[1];
|
|
138
|
+
return {
|
|
139
|
+
key: key,
|
|
140
|
+
target: target,
|
|
141
|
+
mode: ParticleUtil.getTargetMode(key),
|
|
142
|
+
targetName: ParticleUtil.getTargetName(key),
|
|
143
|
+
requiresRuntime: ParticleUtil.requiresRuntime(key, target)
|
|
144
|
+
};
|
|
145
|
+
});
|
|
146
|
+
var _iterator = _createForOfIteratorHelper(entries),
|
|
147
|
+
_step;
|
|
148
|
+
try {
|
|
149
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
150
|
+
var entry = _step.value;
|
|
151
|
+
var cleanKey = TargetUtil.getTargetName(entry.key);
|
|
152
|
+
child.allTargetMap[cleanKey] = entry.key;
|
|
153
|
+
}
|
|
154
|
+
} catch (err) {
|
|
155
|
+
_iterator.e(err);
|
|
156
|
+
} finally {
|
|
157
|
+
_iterator.f();
|
|
158
|
+
}
|
|
159
|
+
var _iterator2 = _createForOfIteratorHelper(entries),
|
|
160
|
+
_step2;
|
|
161
|
+
try {
|
|
162
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
163
|
+
var _entry = _step2.value;
|
|
164
|
+
if (_entry.mode !== "immediate" || ParticleUtil.isFunctionBasedTarget(_entry.target)) {
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
var resolved = ParticleUtil.resolveValue(_entry.target, child);
|
|
168
|
+
var initialValue = ParticleUtil.getInitialValue(resolved);
|
|
169
|
+
ParticleUtil.setInitialValue(child, _entry.targetName, initialValue);
|
|
170
|
+
if (ParticleUtil.isGpuTarget(_entry.key) && !_entry.requiresRuntime) {
|
|
171
|
+
renderDefinition[_entry.targetName] = resolved;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
} catch (err) {
|
|
175
|
+
_iterator2.e(err);
|
|
176
|
+
} finally {
|
|
177
|
+
_iterator2.f();
|
|
178
|
+
}
|
|
179
|
+
var _iterator3 = _createForOfIteratorHelper(entries),
|
|
180
|
+
_step3;
|
|
181
|
+
try {
|
|
182
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
183
|
+
var _entry2 = _step3.value;
|
|
184
|
+
if (_entry2.mode !== "immediate" || !ParticleUtil.isGpuTarget(_entry2.key) || !ParticleUtil.isFunctionBasedTarget(_entry2.target)) {
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
var _resolved = ParticleUtil.resolveValue(_entry2.target, child);
|
|
188
|
+
_entry2.requiresRuntime = ParticleUtil.requiresRuntime(_entry2.key, _resolved);
|
|
189
|
+
if (_entry2.requiresRuntime) {
|
|
190
|
+
var _initialValue = ParticleUtil.getInitialValue(_resolved);
|
|
191
|
+
if (TUtil.isDefined(_initialValue)) {
|
|
192
|
+
renderDefinition[_entry2.targetName] = _initialValue;
|
|
193
|
+
ParticleUtil.setInitialValue(child, _entry2.targetName, _initialValue);
|
|
194
|
+
}
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
renderDefinition[_entry2.targetName] = _resolved;
|
|
198
|
+
ParticleUtil.setInitialValue(child, _entry2.targetName, ParticleUtil.getInitialValue(_resolved));
|
|
199
|
+
var resolvedValue = TargetParser.isTargetSpecObject(_resolved) ? _resolved.value : _resolved;
|
|
200
|
+
if (ParticleUtil.affectsChildLayout(_entry2.targetName) && !Array.isArray(resolvedValue)) {
|
|
201
|
+
runtimeTargets.push({
|
|
202
|
+
key: _entry2.key,
|
|
203
|
+
targetName: _entry2.targetName,
|
|
204
|
+
mode: _entry2.mode,
|
|
205
|
+
target: TargetParser.isTargetSpecObject(_entry2.target) ? _objectSpread({}, _entry2.target) : {
|
|
206
|
+
value: _entry2.target
|
|
207
|
+
},
|
|
208
|
+
requiresRuntime: false,
|
|
209
|
+
requiresInitialResolution: false,
|
|
210
|
+
renderable: true
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
} catch (err) {
|
|
215
|
+
_iterator3.e(err);
|
|
216
|
+
} finally {
|
|
217
|
+
_iterator3.f();
|
|
218
|
+
}
|
|
219
|
+
var _iterator4 = _createForOfIteratorHelper(entries),
|
|
220
|
+
_step4;
|
|
221
|
+
try {
|
|
222
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
223
|
+
var _entry3 = _step4.value;
|
|
224
|
+
if (!_entry3.requiresRuntime) {
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
var requiresInitialResolution = _entry3.mode === "immediate" && ParticleUtil.isGpuTarget(_entry3.key) && ParticleUtil.isFunctionBasedTarget(_entry3.target);
|
|
228
|
+
var runtimeTarget = {
|
|
229
|
+
key: _entry3.key,
|
|
230
|
+
targetName: _entry3.targetName,
|
|
231
|
+
mode: _entry3.mode,
|
|
232
|
+
target: TargetParser.isTargetSpecObject(_entry3.target) ? _objectSpread({}, _entry3.target) : {
|
|
233
|
+
value: _entry3.target
|
|
234
|
+
},
|
|
235
|
+
requiresRuntime: true,
|
|
236
|
+
requiresInitialResolution: requiresInitialResolution,
|
|
237
|
+
renderable: ParticleUtil.isGpuTarget(_entry3.key)
|
|
238
|
+
};
|
|
239
|
+
runtimeTargets.push(runtimeTarget);
|
|
240
|
+
if (ParticleUtil.isGpuTarget(_entry3.key) && _entry3.mode === "immediate" && !ParticleUtil.isFunctionBasedTarget(_entry3.target)) {
|
|
241
|
+
var _resolved2 = ParticleUtil.resolveValue(_entry3.target, child);
|
|
242
|
+
var _initialValue2 = ParticleUtil.getInitialValue(_resolved2);
|
|
243
|
+
renderDefinition[_entry3.targetName] = _initialValue2;
|
|
244
|
+
ParticleUtil.setInitialValue(child, _entry3.targetName, _initialValue2);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
} catch (err) {
|
|
248
|
+
_iterator4.e(err);
|
|
249
|
+
} finally {
|
|
250
|
+
_iterator4.f();
|
|
251
|
+
}
|
|
252
|
+
return {
|
|
253
|
+
renderDefinition: renderDefinition,
|
|
254
|
+
runtimeTargets: runtimeTargets
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
}]);
|
|
258
|
+
}();
|
|
259
|
+
_defineProperty(ParticleUtil, "gpuRenderTargets", new Set(["x", "y", "width", "height", "borderRadius", "backgroundColor", "rotate", "opacity", "scale"]));
|
|
260
|
+
_defineProperty(ParticleUtil, "gpuRenderAliases", {
|
|
261
|
+
background: "backgroundColor"
|
|
262
|
+
});
|
|
263
|
+
_defineProperty(ParticleUtil, "childrenTargets", new Set(["addChildren", "children"]));
|
|
264
|
+
_defineProperty(ParticleUtil, "transientRuntimeFields", new Set(["particleRenderer", "childHandles", "particleValuesDirty", "particleRenderRequested", "pendingGpuChildren", "layoutEpoch", "completeLayoutEpoch", "completeChildrenLayoutState", "layoutCompleteWaiters", "particleSyncPromise", "restoringParticleRuntime"]));
|
|
265
|
+
export { ParticleUtil };
|
package/build/RunScheduler.js
CHANGED
|
@@ -249,9 +249,11 @@ var RunScheduler = /*#__PURE__*/function () {
|
|
|
249
249
|
var newDelay = this.nextRuns.length > 0 ? this.nextRuns[0].delay - (TUtil.now() - this.nextRuns[0].insertTime) : undefined;
|
|
250
250
|
var manager = getManager();
|
|
251
251
|
var hasImmediateWork = manager.lists.restyle.length > 0 || manager.lists.reasyncStyle.length > 0 || getLocationManager().activatedList.length > 0;
|
|
252
|
-
|
|
252
|
+
var hasNoDomVisibilityWork = manager.lists.noDomVisibilityTModels.length > 0;
|
|
253
|
+
if (newDelay === undefined || manager.lists.activeTModels.length > 0 || manager.lists.updatingTModels.length > 0 || hasImmediateWork || hasNoDomVisibilityWork) {
|
|
253
254
|
if (manager.lists.updatingTModels.length > 0) {
|
|
254
255
|
this.schedule(1, "getManager-needsRerun-updatingTModels");
|
|
256
|
+
return;
|
|
255
257
|
} else if (manager.lists.activeTModels.length > 0) {
|
|
256
258
|
var activeTModel = manager.lists.activeTModels.find(function (tmodel) {
|
|
257
259
|
return tmodel.targetExecutionCount === 0 || tmodel.activeTargetList.filter(function (target) {
|
|
@@ -264,10 +266,15 @@ var RunScheduler = /*#__PURE__*/function () {
|
|
|
264
266
|
var delay = !this.activeStartTime || TUtil.now() - this.activeStartTime > 15 ? 1 : 15;
|
|
265
267
|
this.activeStartTime = TUtil.now();
|
|
266
268
|
this.schedule(delay, "getManager-needsRerun-".concat(activeTModel.oid, "-").concat(activeTModel.activeTargetList));
|
|
269
|
+
return;
|
|
267
270
|
}
|
|
268
|
-
}
|
|
271
|
+
}
|
|
272
|
+
if (hasImmediateWork) {
|
|
269
273
|
this.schedule(1, 'needsRerun-dom-work');
|
|
270
274
|
}
|
|
275
|
+
if (hasNoDomVisibilityWork) {
|
|
276
|
+
this.schedule(15, "needsRerun-noDomVisibility");
|
|
277
|
+
}
|
|
271
278
|
}
|
|
272
279
|
}
|
|
273
280
|
this.executeNextRun();
|
|
@@ -402,7 +409,7 @@ var RunScheduler = /*#__PURE__*/function () {
|
|
|
402
409
|
if (runToExecute) {
|
|
403
410
|
this.setDelayProcess(runToExecute.runId, runToExecute.insertTime, runToExecute.delay, TUtil.now(), 0);
|
|
404
411
|
} else if (this.nextRuns.length > 0) {
|
|
405
|
-
var nextValidRun = this.nextRuns
|
|
412
|
+
var nextValidRun = this.nextRuns.shift();
|
|
406
413
|
var _now = TUtil.now();
|
|
407
414
|
var _newDelay = Math.max(0, nextValidRun.delay - (_now - nextValidRun.insertTime));
|
|
408
415
|
this.setDelayProcess(nextValidRun.runId, nextValidRun.insertTime, nextValidRun.delay, _now + _newDelay, _newDelay);
|
package/build/ScheduleUtil.js
CHANGED
|
@@ -103,13 +103,13 @@ var ScheduleUtil = /*#__PURE__*/function () {
|
|
|
103
103
|
if (TUtil.isDefined(remaining)) {
|
|
104
104
|
ScheduleUtil.resumeSchedule(tmodel, key);
|
|
105
105
|
tmodel.addTargetToStatusList(key);
|
|
106
|
-
getRunScheduler().scheduleOnlyIfEarlier(remaining, "
|
|
106
|
+
getRunScheduler().scheduleOnlyIfEarlier(remaining, "resume1-".concat(tmodel.oid, "-").concat(key));
|
|
107
107
|
continue;
|
|
108
108
|
}
|
|
109
109
|
if (TUtil.isDefined(tmodel.getScheduleTimeStamp(key))) {
|
|
110
110
|
var delay = ScheduleUtil.scheduleExecution(tmodel, key);
|
|
111
111
|
tmodel.addTargetToStatusList(key);
|
|
112
|
-
getRunScheduler().scheduleOnlyIfEarlier(delay, "
|
|
112
|
+
getRunScheduler().scheduleOnlyIfEarlier(delay, "resume2-".concat(tmodel.oid, "-").concat(key));
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
} catch (err) {
|
package/build/StateManager.js
CHANGED
|
@@ -26,9 +26,9 @@ import { tApp, App, getRunScheduler, getLocationManager, getAnimationManager, ge
|
|
|
26
26
|
import { AnimationUtil } from "./AnimationUtil.js";
|
|
27
27
|
import { DomInit } from "./DomInit.js";
|
|
28
28
|
import { $Dom } from "./$Dom.js";
|
|
29
|
-
import { TModel } from "./TModel.js";
|
|
30
29
|
import { TargetUtil } from "./TargetUtil.js";
|
|
31
30
|
import { TModelUtil } from "./TModelUtil.js";
|
|
31
|
+
import { TModel } from "./TModel.js";
|
|
32
32
|
import { StateUtil } from "./StateUtil.js";
|
|
33
33
|
/**
|
|
34
34
|
* It enables storing and restoring state.
|
|
@@ -54,22 +54,39 @@ var StateManager = /*#__PURE__*/function () {
|
|
|
54
54
|
this.syncAnimationsForCheckpoint();
|
|
55
55
|
runSnapshot = getRunScheduler().getSnapshot();
|
|
56
56
|
$pageDom = TModelUtil.getPageDom();
|
|
57
|
+
_context.t0 = key;
|
|
58
|
+
_context.t1 = TUtil.now();
|
|
59
|
+
_context.t2 = $pageDom.innerHTML();
|
|
60
|
+
_context.t3 = TModelUtil.captureDomState($pageDom);
|
|
61
|
+
_context.t4 = _objectSpread({}, App.oids);
|
|
62
|
+
_context.t5 = tApp.tRoot.createRuntimeSnapshot();
|
|
63
|
+
_context.t6 = getLoader().createRuntimeSnapshot();
|
|
64
|
+
_context.t7 = Object.keys(tApp.manager.visibleOidMap);
|
|
65
|
+
_context.t8 = $Dom.getWindowScrollLeft() || 0;
|
|
66
|
+
_context.t9 = $Dom.getWindowScrollTop() || 0;
|
|
67
|
+
_context.t10 = runSnapshot;
|
|
68
|
+
_context.next = 17;
|
|
69
|
+
return this.captureGpuVisuals();
|
|
70
|
+
case 17:
|
|
71
|
+
_context.t11 = _context.sent;
|
|
57
72
|
checkpoint = {
|
|
58
|
-
key:
|
|
59
|
-
capturedAt:
|
|
60
|
-
html:
|
|
61
|
-
domState:
|
|
62
|
-
oids:
|
|
63
|
-
rootSnapshot:
|
|
64
|
-
loaderSnapshot:
|
|
65
|
-
visibleOids:
|
|
66
|
-
scrollLeft:
|
|
67
|
-
scrollTop:
|
|
68
|
-
runSnapshot:
|
|
73
|
+
key: _context.t0,
|
|
74
|
+
capturedAt: _context.t1,
|
|
75
|
+
html: _context.t2,
|
|
76
|
+
domState: _context.t3,
|
|
77
|
+
oids: _context.t4,
|
|
78
|
+
rootSnapshot: _context.t5,
|
|
79
|
+
loaderSnapshot: _context.t6,
|
|
80
|
+
visibleOids: _context.t7,
|
|
81
|
+
scrollLeft: _context.t8,
|
|
82
|
+
scrollTop: _context.t9,
|
|
83
|
+
runSnapshot: _context.t10,
|
|
84
|
+
gpuVisuals: _context.t11
|
|
69
85
|
};
|
|
86
|
+
this.releaseGpuVisuals(this.stateCheckpoints[key]);
|
|
70
87
|
this.stateCheckpoints[key] = checkpoint;
|
|
71
88
|
return _context.abrupt("return", checkpoint);
|
|
72
|
-
case
|
|
89
|
+
case 22:
|
|
73
90
|
case "end":
|
|
74
91
|
return _context.stop();
|
|
75
92
|
}
|
|
@@ -93,6 +110,7 @@ var StateManager = /*#__PURE__*/function () {
|
|
|
93
110
|
models,
|
|
94
111
|
$pageDom,
|
|
95
112
|
visibleModels,
|
|
113
|
+
restoredWithDom,
|
|
96
114
|
$restoredPageDom,
|
|
97
115
|
_args2 = arguments;
|
|
98
116
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
@@ -128,27 +146,38 @@ var StateManager = /*#__PURE__*/function () {
|
|
|
128
146
|
getLoader().restoreRuntimeSnapshot(checkpoint.loaderSnapshot, tmodelIdMap);
|
|
129
147
|
$pageDom = TModelUtil.getPageDom();
|
|
130
148
|
$pageDom.innerHTML(checkpoint.html);
|
|
131
|
-
TModelUtil.
|
|
149
|
+
TModelUtil.restoreMountedDom($pageDom, checkpoint.domState);
|
|
150
|
+
this.showGpuRestoreVisuals(checkpoint.gpuVisuals);
|
|
132
151
|
tApp.tRoot.$dom = TModelUtil.getRootDom();
|
|
133
152
|
visibleModels = checkpoint.visibleOids.map(function (oid) {
|
|
134
153
|
return tmodelIdMap[oid];
|
|
135
154
|
}).filter(Boolean);
|
|
136
|
-
this.connectRestoredDoms(visibleModels, models);
|
|
155
|
+
restoredWithDom = this.connectRestoredDoms(visibleModels, models);
|
|
156
|
+
tApp.manager.activatePendingTargetsAfterDom(restoredWithDom, {
|
|
157
|
+
restoredDoneTargets: true
|
|
158
|
+
});
|
|
137
159
|
tApp.tRoot.markLayoutDirty("checkpointRestore");
|
|
138
|
-
_context2.next =
|
|
160
|
+
_context2.next = 31;
|
|
139
161
|
return tApp.start();
|
|
140
|
-
case
|
|
141
|
-
getRunScheduler().restoreSnapshot(checkpoint.runSnapshot);
|
|
162
|
+
case 31:
|
|
142
163
|
$restoredPageDom = TModelUtil.getPageDom();
|
|
143
|
-
TModelUtil.
|
|
144
|
-
_context2.next =
|
|
164
|
+
TModelUtil.restoreMountedDom($restoredPageDom, checkpoint.domState);
|
|
165
|
+
_context2.next = 35;
|
|
145
166
|
return TModelUtil.restoreScroll(checkpoint);
|
|
146
|
-
case
|
|
147
|
-
_context2.next =
|
|
167
|
+
case 35:
|
|
168
|
+
_context2.next = 37;
|
|
148
169
|
return TModelUtil.restoreDomInteractionState($restoredPageDom, checkpoint.domState);
|
|
149
|
-
case 36:
|
|
150
|
-
return _context2.abrupt("return", true);
|
|
151
170
|
case 37:
|
|
171
|
+
_context2.next = 39;
|
|
172
|
+
return Promise.all(models.map(function (tmodel) {
|
|
173
|
+
var _tmodel$restoreRuntim;
|
|
174
|
+
return (_tmodel$restoreRuntim = tmodel.restoreRuntimeDomDerivedState) === null || _tmodel$restoreRuntim === void 0 ? void 0 : _tmodel$restoreRuntim.call(tmodel);
|
|
175
|
+
}));
|
|
176
|
+
case 39:
|
|
177
|
+
this.hideGpuRestoreVisuals();
|
|
178
|
+
getRunScheduler().restoreSnapshot(checkpoint.runSnapshot);
|
|
179
|
+
return _context2.abrupt("return", true);
|
|
180
|
+
case 42:
|
|
152
181
|
case "end":
|
|
153
182
|
return _context2.stop();
|
|
154
183
|
}
|
|
@@ -232,8 +261,8 @@ var StateManager = /*#__PURE__*/function () {
|
|
|
232
261
|
}, {
|
|
233
262
|
key: "connectRestoredDoms",
|
|
234
263
|
value: function connectRestoredDoms(visibleModels, allModels) {
|
|
235
|
-
var
|
|
236
|
-
var restoredWithDom = TUtil.uniqueTModels([].concat(_toConsumableArray(visibleModels), _toConsumableArray(
|
|
264
|
+
var restoredDoms = DomInit.initCacheDoms(visibleModels);
|
|
265
|
+
var restoredWithDom = TUtil.uniqueTModels([].concat(_toConsumableArray(visibleModels), _toConsumableArray(restoredDoms)));
|
|
237
266
|
this.normalizeRestoredModels(allModels);
|
|
238
267
|
tApp.manager.visibleOidMap = {};
|
|
239
268
|
var _iterator4 = _createForOfIteratorHelper(restoredWithDom),
|
|
@@ -241,7 +270,7 @@ var StateManager = /*#__PURE__*/function () {
|
|
|
241
270
|
try {
|
|
242
271
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
243
272
|
var tmodel = _step4.value;
|
|
244
|
-
if (tmodel.isIncluded()) {
|
|
273
|
+
if (tmodel.isIncluded() && tmodel.isVisible()) {
|
|
245
274
|
tApp.manager.visibleOidMap[tmodel.oid] = tmodel;
|
|
246
275
|
}
|
|
247
276
|
}
|
|
@@ -250,11 +279,180 @@ var StateManager = /*#__PURE__*/function () {
|
|
|
250
279
|
} finally {
|
|
251
280
|
_iterator4.f();
|
|
252
281
|
}
|
|
253
|
-
tApp.manager.activatePendingTargetsAfterDom(restoredWithDom, {
|
|
254
|
-
restoredDoneTargets: true
|
|
255
|
-
});
|
|
256
282
|
return restoredWithDom;
|
|
257
283
|
}
|
|
284
|
+
}, {
|
|
285
|
+
key: "getGpuVisualClipRect",
|
|
286
|
+
value: function getGpuVisualClipRect(element) {
|
|
287
|
+
var rect = element.getBoundingClientRect();
|
|
288
|
+
var left = Math.max(0, rect.left);
|
|
289
|
+
var top = Math.max(0, rect.top);
|
|
290
|
+
var right = Math.min(window.innerWidth, rect.right);
|
|
291
|
+
var bottom = Math.min(window.innerHeight, rect.bottom);
|
|
292
|
+
for (var parent = element.parentElement; parent; parent = parent.parentElement) {
|
|
293
|
+
var style = getComputedStyle(parent);
|
|
294
|
+
var parentRect = parent.getBoundingClientRect();
|
|
295
|
+
var clipsX = ["hidden", "clip", "auto", "scroll"].includes(style.overflowX);
|
|
296
|
+
var clipsY = ["hidden", "clip", "auto", "scroll"].includes(style.overflowY);
|
|
297
|
+
if (clipsX) {
|
|
298
|
+
left = Math.max(left, parentRect.left);
|
|
299
|
+
right = Math.min(right, parentRect.right);
|
|
300
|
+
}
|
|
301
|
+
if (clipsY) {
|
|
302
|
+
top = Math.max(top, parentRect.top);
|
|
303
|
+
bottom = Math.min(bottom, parentRect.bottom);
|
|
304
|
+
}
|
|
305
|
+
if (right <= left || bottom <= top) {
|
|
306
|
+
return {
|
|
307
|
+
left: left,
|
|
308
|
+
top: top,
|
|
309
|
+
width: 0,
|
|
310
|
+
height: 0
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return {
|
|
315
|
+
left: left,
|
|
316
|
+
top: top,
|
|
317
|
+
width: right - left,
|
|
318
|
+
height: bottom - top
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
}, {
|
|
322
|
+
key: "captureGpuVisuals",
|
|
323
|
+
value: function () {
|
|
324
|
+
var _captureGpuVisuals = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
325
|
+
var visuals, _i, _Object$values, tmodel, renderer, canvas, rect, clipRect, bitmap;
|
|
326
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
327
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
328
|
+
case 0:
|
|
329
|
+
visuals = {};
|
|
330
|
+
_i = 0, _Object$values = Object.values(App.tmodelIdMap);
|
|
331
|
+
case 2:
|
|
332
|
+
if (!(_i < _Object$values.length)) {
|
|
333
|
+
_context3.next = 21;
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
tmodel = _Object$values[_i];
|
|
337
|
+
renderer = tmodel.particleRenderer;
|
|
338
|
+
canvas = renderer === null || renderer === void 0 ? void 0 : renderer.canvas;
|
|
339
|
+
if (!(!canvas || !tmodel.gpuChildrenEnabled)) {
|
|
340
|
+
_context3.next = 8;
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
return _context3.abrupt("continue", 18);
|
|
344
|
+
case 8:
|
|
345
|
+
rect = canvas.getBoundingClientRect();
|
|
346
|
+
clipRect = this.getGpuVisualClipRect(canvas);
|
|
347
|
+
if (!(clipRect.width <= 0 || clipRect.height <= 0)) {
|
|
348
|
+
_context3.next = 12;
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
351
|
+
return _context3.abrupt("continue", 18);
|
|
352
|
+
case 12:
|
|
353
|
+
_context3.next = 14;
|
|
354
|
+
return renderer.captureBitmap();
|
|
355
|
+
case 14:
|
|
356
|
+
bitmap = _context3.sent;
|
|
357
|
+
if (bitmap) {
|
|
358
|
+
_context3.next = 17;
|
|
359
|
+
break;
|
|
360
|
+
}
|
|
361
|
+
return _context3.abrupt("continue", 18);
|
|
362
|
+
case 17:
|
|
363
|
+
visuals[tmodel.oid] = {
|
|
364
|
+
bitmap: bitmap,
|
|
365
|
+
left: rect.left,
|
|
366
|
+
top: rect.top,
|
|
367
|
+
width: rect.width,
|
|
368
|
+
height: rect.height,
|
|
369
|
+
clipLeft: clipRect.left,
|
|
370
|
+
clipTop: clipRect.top,
|
|
371
|
+
clipWidth: clipRect.width,
|
|
372
|
+
clipHeight: clipRect.height
|
|
373
|
+
};
|
|
374
|
+
case 18:
|
|
375
|
+
_i++;
|
|
376
|
+
_context3.next = 2;
|
|
377
|
+
break;
|
|
378
|
+
case 21:
|
|
379
|
+
return _context3.abrupt("return", visuals);
|
|
380
|
+
case 22:
|
|
381
|
+
case "end":
|
|
382
|
+
return _context3.stop();
|
|
383
|
+
}
|
|
384
|
+
}, _callee3, this);
|
|
385
|
+
}));
|
|
386
|
+
function captureGpuVisuals() {
|
|
387
|
+
return _captureGpuVisuals.apply(this, arguments);
|
|
388
|
+
}
|
|
389
|
+
return captureGpuVisuals;
|
|
390
|
+
}()
|
|
391
|
+
}, {
|
|
392
|
+
key: "showGpuRestoreVisuals",
|
|
393
|
+
value: function showGpuRestoreVisuals(visuals) {
|
|
394
|
+
this.hideGpuRestoreVisuals();
|
|
395
|
+
if (!Object.keys(visuals || {}).length) {
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
var overlay = document.createElement("div");
|
|
399
|
+
overlay.setAttribute("data-targetjs-gpu-restore-overlay", "true");
|
|
400
|
+
Object.assign(overlay.style, {
|
|
401
|
+
position: "fixed",
|
|
402
|
+
left: "0px",
|
|
403
|
+
top: "0px",
|
|
404
|
+
width: "100vw",
|
|
405
|
+
height: "100vh",
|
|
406
|
+
pointerEvents: "none",
|
|
407
|
+
zIndex: "2147483647"
|
|
408
|
+
});
|
|
409
|
+
for (var _i2 = 0, _Object$values2 = Object.values(visuals); _i2 < _Object$values2.length; _i2++) {
|
|
410
|
+
var visual = _Object$values2[_i2];
|
|
411
|
+
if (!(visual !== null && visual !== void 0 && visual.bitmap) || visual.clipWidth <= 0 || visual.clipHeight <= 0) {
|
|
412
|
+
continue;
|
|
413
|
+
}
|
|
414
|
+
var clip = document.createElement("div");
|
|
415
|
+
Object.assign(clip.style, {
|
|
416
|
+
position: "absolute",
|
|
417
|
+
left: "".concat(visual.clipLeft, "px"),
|
|
418
|
+
top: "".concat(visual.clipTop, "px"),
|
|
419
|
+
width: "".concat(visual.clipWidth, "px"),
|
|
420
|
+
height: "".concat(visual.clipHeight, "px"),
|
|
421
|
+
overflow: "hidden"
|
|
422
|
+
});
|
|
423
|
+
var preview = document.createElement("canvas");
|
|
424
|
+
preview.width = visual.bitmap.width;
|
|
425
|
+
preview.height = visual.bitmap.height;
|
|
426
|
+
Object.assign(preview.style, {
|
|
427
|
+
position: "absolute",
|
|
428
|
+
left: "".concat(visual.left - visual.clipLeft, "px"),
|
|
429
|
+
top: "".concat(visual.top - visual.clipTop, "px"),
|
|
430
|
+
width: "".concat(visual.width, "px"),
|
|
431
|
+
height: "".concat(visual.height, "px"),
|
|
432
|
+
display: "block"
|
|
433
|
+
});
|
|
434
|
+
preview.getContext("2d").drawImage(visual.bitmap, 0, 0);
|
|
435
|
+
clip.appendChild(preview);
|
|
436
|
+
overlay.appendChild(clip);
|
|
437
|
+
}
|
|
438
|
+
document.body.appendChild(overlay);
|
|
439
|
+
return overlay;
|
|
440
|
+
}
|
|
441
|
+
}, {
|
|
442
|
+
key: "hideGpuRestoreVisuals",
|
|
443
|
+
value: function hideGpuRestoreVisuals() {
|
|
444
|
+
var _document$querySelect;
|
|
445
|
+
(_document$querySelect = document.querySelector('[data-targetjs-gpu-restore-overlay="true"]')) === null || _document$querySelect === void 0 || _document$querySelect.remove();
|
|
446
|
+
}
|
|
447
|
+
}, {
|
|
448
|
+
key: "releaseGpuVisuals",
|
|
449
|
+
value: function releaseGpuVisuals(checkpoint) {
|
|
450
|
+
for (var _i3 = 0, _Object$values3 = Object.values((checkpoint === null || checkpoint === void 0 ? void 0 : checkpoint.gpuVisuals) || {}); _i3 < _Object$values3.length; _i3++) {
|
|
451
|
+
var _visual$bitmap, _visual$bitmap$close, _visual$bitmap2;
|
|
452
|
+
var visual = _Object$values3[_i3];
|
|
453
|
+
visual === null || visual === void 0 || (_visual$bitmap = visual.bitmap) === null || _visual$bitmap === void 0 || (_visual$bitmap$close = (_visual$bitmap2 = _visual$bitmap).close) === null || _visual$bitmap$close === void 0 || _visual$bitmap$close.call(_visual$bitmap2);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
258
456
|
}, {
|
|
259
457
|
key: "has",
|
|
260
458
|
value: function has() {
|
|
@@ -277,15 +475,21 @@ var StateManager = /*#__PURE__*/function () {
|
|
|
277
475
|
key: "clear",
|
|
278
476
|
value: function clear() {
|
|
279
477
|
var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "default";
|
|
280
|
-
|
|
478
|
+
var checkpoint = this.stateCheckpoints[key];
|
|
479
|
+
if (!checkpoint) {
|
|
281
480
|
return false;
|
|
282
481
|
}
|
|
482
|
+
this.releaseGpuVisuals(checkpoint);
|
|
283
483
|
delete this.stateCheckpoints[key];
|
|
284
484
|
return true;
|
|
285
485
|
}
|
|
286
486
|
}, {
|
|
287
487
|
key: "clearAll",
|
|
288
488
|
value: function clearAll() {
|
|
489
|
+
for (var _i4 = 0, _Object$values4 = Object.values(this.stateCheckpoints); _i4 < _Object$values4.length; _i4++) {
|
|
490
|
+
var checkpoint = _Object$values4[_i4];
|
|
491
|
+
this.releaseGpuVisuals(checkpoint);
|
|
492
|
+
}
|
|
289
493
|
this.stateCheckpoints = {};
|
|
290
494
|
}
|
|
291
495
|
}]);
|