targetj 1.0.258 → 1.0.260
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 +13 -1
- package/README.md +18 -25
- package/build/AnimationUtil.js +1 -8
- package/build/App.js +3 -2
- package/build/BaseModel.js +31 -10
- package/build/Child.js +504 -0
- package/build/LocationManager.js +30 -0
- package/build/ParticleRenderer.js +637 -0
- package/build/ParticleRuntime.js +898 -0
- package/build/ParticleTModel.js +1040 -0
- package/build/ParticleUtil.js +317 -0
- package/build/ScheduleUtil.js +2 -2
- package/build/StateManager.js +173 -26
- package/build/StateUtil.js +13 -14
- package/build/TModel.js +61 -27
- package/build/TModelFactory.js +48 -0
- package/build/TModelManager.js +55 -22
- package/build/TUtil.js +8 -3
- package/build/TargetData.js +4 -4
- package/build/TargetExecutor.js +52 -6
- package/build/TargetManager.js +5 -2
- package/build/TargetParser.js +19 -2
- package/build/TargetUtil.js +2 -2
- package/build/Viewport.js +2 -2
- package/build/index.js +5 -1
- package/dist/targetjs.js +1 -1
- package/dist/targetjs.js.gz +0 -0
- package/package.json +1 -1
- package/types/app.d.ts +56 -0
- package/types/attributes.d.ts +37 -0
- package/types/core.d.ts +154 -0
- package/types/events.d.ts +41 -0
- package/types/index.d.ts +29 -287
- package/types/state.d.ts +48 -0
- package/types/styles.d.ts +103 -0
- package/types/tmodel.d.ts +89 -0
- package/types/utilities.d.ts +37 -0
|
@@ -0,0 +1,317 @@
|
|
|
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 { TargetData } from "./TargetData.js";
|
|
18
|
+
import { TargetParser } from "./TargetParser.js";
|
|
19
|
+
import { TargetUtil } from "./TargetUtil.js";
|
|
20
|
+
import { TUtil } from "./TUtil.js";
|
|
21
|
+
var ParticleUtil = /*#__PURE__*/function () {
|
|
22
|
+
function ParticleUtil() {
|
|
23
|
+
_classCallCheck(this, ParticleUtil);
|
|
24
|
+
}
|
|
25
|
+
return _createClass(ParticleUtil, null, [{
|
|
26
|
+
key: "isGpuChildrenTarget",
|
|
27
|
+
value: function isGpuChildrenTarget(key) {
|
|
28
|
+
return ParticleUtil.gpuChildrenTargets.has(TargetUtil.getTargetName(key));
|
|
29
|
+
}
|
|
30
|
+
}, {
|
|
31
|
+
key: "getGpuRenderTargetName",
|
|
32
|
+
value: function getGpuRenderTargetName(key) {
|
|
33
|
+
var cleanKey = TargetUtil.getTargetName(key);
|
|
34
|
+
return ParticleUtil.gpuRenderAliases[cleanKey] || cleanKey;
|
|
35
|
+
}
|
|
36
|
+
}, {
|
|
37
|
+
key: "isGpuRenderTarget",
|
|
38
|
+
value: function isGpuRenderTarget(key) {
|
|
39
|
+
return ParticleUtil.gpuRenderTargets.has(ParticleUtil.getGpuRenderTargetName(key));
|
|
40
|
+
}
|
|
41
|
+
}, {
|
|
42
|
+
key: "isIgnoredGpuStyleTarget",
|
|
43
|
+
value: function isIgnoredGpuStyleTarget(key) {
|
|
44
|
+
var cleanKey = TargetUtil.getTargetName(key);
|
|
45
|
+
return TargetData.styleSet.has(cleanKey) && !ParticleUtil.isGpuRenderTarget(cleanKey);
|
|
46
|
+
}
|
|
47
|
+
}, {
|
|
48
|
+
key: "affectsChildLayout",
|
|
49
|
+
value: function affectsChildLayout(key) {
|
|
50
|
+
return ParticleUtil.childLayoutTargets.has(ParticleUtil.getGpuRenderTargetName(key));
|
|
51
|
+
}
|
|
52
|
+
}, {
|
|
53
|
+
key: "getGpuTargetMode",
|
|
54
|
+
value: function getGpuTargetMode(key) {
|
|
55
|
+
if (key.endsWith("$$")) {
|
|
56
|
+
return "deferred";
|
|
57
|
+
}
|
|
58
|
+
if (key.endsWith("$")) {
|
|
59
|
+
return "reactive";
|
|
60
|
+
}
|
|
61
|
+
return "immediate";
|
|
62
|
+
}
|
|
63
|
+
}, {
|
|
64
|
+
key: "classifyGpuChildTarget",
|
|
65
|
+
value: function classifyGpuChildTarget(key, value) {
|
|
66
|
+
/*
|
|
67
|
+
* Interval is a property of the target definition, not the target name.
|
|
68
|
+
* Check it before render/style classification.
|
|
69
|
+
*/
|
|
70
|
+
if (TargetParser.isIntervalTarget(value)) {
|
|
71
|
+
return "interval";
|
|
72
|
+
}
|
|
73
|
+
if (ParticleUtil.isGpuRenderTarget(key)) {
|
|
74
|
+
return "render";
|
|
75
|
+
}
|
|
76
|
+
if (ParticleUtil.isIgnoredGpuStyleTarget(key)) {
|
|
77
|
+
return "ignoredStyle";
|
|
78
|
+
}
|
|
79
|
+
return "runtime";
|
|
80
|
+
}
|
|
81
|
+
}, {
|
|
82
|
+
key: "isTransientRuntimeField",
|
|
83
|
+
value: function isTransientRuntimeField(key) {
|
|
84
|
+
return ParticleUtil.transientRuntimeFields.has(key);
|
|
85
|
+
}
|
|
86
|
+
}, {
|
|
87
|
+
key: "isFunctionBasedGpuValue",
|
|
88
|
+
value: function isFunctionBasedGpuValue(value) {
|
|
89
|
+
if (typeof value === "function") {
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
return TargetParser.isTargetSpecObject(value) && typeof value.value === "function";
|
|
93
|
+
}
|
|
94
|
+
}, {
|
|
95
|
+
key: "resolveGpuRenderValue",
|
|
96
|
+
value: function resolveGpuRenderValue(value, child) {
|
|
97
|
+
if (typeof value === "function") {
|
|
98
|
+
return value.call(child);
|
|
99
|
+
}
|
|
100
|
+
if (!TargetParser.isTargetSpecObject(value)) {
|
|
101
|
+
return value;
|
|
102
|
+
}
|
|
103
|
+
var resolved = _objectSpread({}, value);
|
|
104
|
+
if (typeof resolved.value === "function") {
|
|
105
|
+
resolved.value = resolved.value.call(child);
|
|
106
|
+
}
|
|
107
|
+
return resolved;
|
|
108
|
+
}
|
|
109
|
+
}, {
|
|
110
|
+
key: "getGpuInitialRenderValue",
|
|
111
|
+
value: function getGpuInitialRenderValue(value) {
|
|
112
|
+
if (!TargetParser.isTargetSpecObject(value)) {
|
|
113
|
+
return value;
|
|
114
|
+
}
|
|
115
|
+
if (Array.isArray(value.value)) {
|
|
116
|
+
return value.value[0];
|
|
117
|
+
}
|
|
118
|
+
return value.value;
|
|
119
|
+
}
|
|
120
|
+
}, {
|
|
121
|
+
key: "setGpuInitialChildValue",
|
|
122
|
+
value: function setGpuInitialChildValue(child, key, value) {
|
|
123
|
+
if (!child || !TUtil.isDefined(value)) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
child.val(key, value);
|
|
127
|
+
}
|
|
128
|
+
}, {
|
|
129
|
+
key: "createGpuRuntimeTarget",
|
|
130
|
+
value: function createGpuRuntimeTarget(key, value) {
|
|
131
|
+
return {
|
|
132
|
+
key: key,
|
|
133
|
+
targetName: ParticleUtil.getGpuRenderTargetName(key),
|
|
134
|
+
kind: ParticleUtil.classifyGpuChildTarget(key, value),
|
|
135
|
+
mode: ParticleUtil.getGpuTargetMode(key),
|
|
136
|
+
target: TargetParser.isTargetSpecObject(value) ? _objectSpread({}, value) : {
|
|
137
|
+
value: value
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}, {
|
|
142
|
+
key: "requiresGpuChildRuntime",
|
|
143
|
+
value: function requiresGpuChildRuntime(key, value) {
|
|
144
|
+
var mode = ParticleUtil.getGpuTargetMode(key);
|
|
145
|
+
var kind = ParticleUtil.classifyGpuChildTarget(key, value);
|
|
146
|
+
if (kind === "interval" || kind === "runtime") {
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
if (mode !== "immediate") {
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
if (!ParticleUtil.isGpuRenderTarget(key)) {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/*
|
|
157
|
+
* A plain render function such as x() or backgroundColor() can simply
|
|
158
|
+
* be resolved immediately. It does not require an animation runtime.
|
|
159
|
+
*/
|
|
160
|
+
if (typeof value === "function") {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
if (!TargetParser.isTargetSpecObject(value)) {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/*
|
|
168
|
+
* Simple GPU transitions such as:
|
|
169
|
+
*
|
|
170
|
+
* x: {
|
|
171
|
+
* value: [0, 500],
|
|
172
|
+
* steps: 100
|
|
173
|
+
* }
|
|
174
|
+
*
|
|
175
|
+
* can continue using the existing bulk GPU transition path.
|
|
176
|
+
*
|
|
177
|
+
* Targets with their own execution timing or function-valued value
|
|
178
|
+
* require the lightweight child runtime.
|
|
179
|
+
*/
|
|
180
|
+
return typeof value.value === "function" || TUtil.isDefined(value.interval) || TUtil.isDefined(value.easing) || TUtil.isDefined(value.cycles) || TUtil.isDefined(value.loop);
|
|
181
|
+
}
|
|
182
|
+
}, {
|
|
183
|
+
key: "compileGpuChildDefinition",
|
|
184
|
+
value: function compileGpuChildDefinition(child, definition) {
|
|
185
|
+
var renderDefinition = {};
|
|
186
|
+
var runtimeTargets = [];
|
|
187
|
+
var ignoredStyles = [];
|
|
188
|
+
var layoutFunctions = [];
|
|
189
|
+
var entries = Object.entries(definition).map(function (_ref) {
|
|
190
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
191
|
+
key = _ref2[0],
|
|
192
|
+
value = _ref2[1];
|
|
193
|
+
return {
|
|
194
|
+
key: key,
|
|
195
|
+
value: value,
|
|
196
|
+
kind: ParticleUtil.classifyGpuChildTarget(key, value),
|
|
197
|
+
mode: ParticleUtil.getGpuTargetMode(key),
|
|
198
|
+
targetName: ParticleUtil.getGpuRenderTargetName(key),
|
|
199
|
+
requiresRuntime: ParticleUtil.requiresGpuChildRuntime(key, value)
|
|
200
|
+
};
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
/*
|
|
204
|
+
* Resolve ordinary immediate non-function render values first.
|
|
205
|
+
*
|
|
206
|
+
* This seeds width/height/etc. before x() and other functions execute.
|
|
207
|
+
*/
|
|
208
|
+
var _iterator = _createForOfIteratorHelper(entries),
|
|
209
|
+
_step;
|
|
210
|
+
try {
|
|
211
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
212
|
+
var entry = _step.value;
|
|
213
|
+
if (entry.kind !== "render" || entry.mode !== "immediate" || entry.requiresRuntime || ParticleUtil.isFunctionBasedGpuValue(entry.value)) {
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
var resolved = ParticleUtil.resolveGpuRenderValue(entry.value, child);
|
|
217
|
+
renderDefinition[entry.targetName] = resolved;
|
|
218
|
+
ParticleUtil.setGpuInitialChildValue(child, entry.targetName, ParticleUtil.getGpuInitialRenderValue(resolved));
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/*
|
|
222
|
+
* Resolve plain immediate function-valued render targets after
|
|
223
|
+
* static dimensions have been initialized.
|
|
224
|
+
*
|
|
225
|
+
* Keep layout functions so they can be recalculated after the
|
|
226
|
+
* parent's first layout.
|
|
227
|
+
*/
|
|
228
|
+
} catch (err) {
|
|
229
|
+
_iterator.e(err);
|
|
230
|
+
} finally {
|
|
231
|
+
_iterator.f();
|
|
232
|
+
}
|
|
233
|
+
var _iterator2 = _createForOfIteratorHelper(entries),
|
|
234
|
+
_step2;
|
|
235
|
+
try {
|
|
236
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
237
|
+
var _entry = _step2.value;
|
|
238
|
+
if (_entry.kind !== "render" || _entry.mode !== "immediate" || _entry.requiresRuntime || !ParticleUtil.isFunctionBasedGpuValue(_entry.value)) {
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
var _resolved = ParticleUtil.resolveGpuRenderValue(_entry.value, child);
|
|
242
|
+
renderDefinition[_entry.targetName] = _resolved;
|
|
243
|
+
ParticleUtil.setGpuInitialChildValue(child, _entry.targetName, ParticleUtil.getGpuInitialRenderValue(_resolved));
|
|
244
|
+
if (ParticleUtil.affectsChildLayout(_entry.targetName)) {
|
|
245
|
+
layoutFunctions.push({
|
|
246
|
+
key: _entry.key,
|
|
247
|
+
targetName: _entry.targetName,
|
|
248
|
+
value: _entry.value
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/*
|
|
254
|
+
* Preserve runtime targets in their original code order.
|
|
255
|
+
*/
|
|
256
|
+
} catch (err) {
|
|
257
|
+
_iterator2.e(err);
|
|
258
|
+
} finally {
|
|
259
|
+
_iterator2.f();
|
|
260
|
+
}
|
|
261
|
+
var _iterator3 = _createForOfIteratorHelper(entries),
|
|
262
|
+
_step3;
|
|
263
|
+
try {
|
|
264
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
265
|
+
var _entry2 = _step3.value;
|
|
266
|
+
if (_entry2.kind === "ignoredStyle") {
|
|
267
|
+
ignoredStyles.push(_entry2.key);
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
if (!_entry2.requiresRuntime) {
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
runtimeTargets.push(ParticleUtil.createGpuRuntimeTarget(_entry2.key, _entry2.value));
|
|
274
|
+
|
|
275
|
+
/*
|
|
276
|
+
* An immediate animated render target needs an initial GPU-visible
|
|
277
|
+
* value, but the animation itself belongs to childRuntimePrograms.
|
|
278
|
+
*
|
|
279
|
+
* Example:
|
|
280
|
+
*
|
|
281
|
+
* y: {
|
|
282
|
+
* value() { return [0, 500]; },
|
|
283
|
+
* steps: 30,
|
|
284
|
+
* interval: 20
|
|
285
|
+
* }
|
|
286
|
+
*
|
|
287
|
+
* renderDefinition gets y: 0.
|
|
288
|
+
*/
|
|
289
|
+
if (_entry2.kind === "render" && _entry2.mode === "immediate") {
|
|
290
|
+
var _resolved2 = ParticleUtil.resolveGpuRenderValue(_entry2.value, child);
|
|
291
|
+
var initialValue = ParticleUtil.getGpuInitialRenderValue(_resolved2);
|
|
292
|
+
renderDefinition[_entry2.targetName] = initialValue;
|
|
293
|
+
ParticleUtil.setGpuInitialChildValue(child, _entry2.targetName, initialValue);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
} catch (err) {
|
|
297
|
+
_iterator3.e(err);
|
|
298
|
+
} finally {
|
|
299
|
+
_iterator3.f();
|
|
300
|
+
}
|
|
301
|
+
return {
|
|
302
|
+
renderDefinition: renderDefinition,
|
|
303
|
+
runtimeTargets: runtimeTargets,
|
|
304
|
+
ignoredStyles: ignoredStyles,
|
|
305
|
+
layoutFunctions: layoutFunctions
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
}]);
|
|
309
|
+
}();
|
|
310
|
+
_defineProperty(ParticleUtil, "gpuRenderTargets", new Set(["x", "y", "width", "height", "borderRadius", "backgroundColor", "rotate"]));
|
|
311
|
+
_defineProperty(ParticleUtil, "gpuRenderAliases", {
|
|
312
|
+
background: "backgroundColor"
|
|
313
|
+
});
|
|
314
|
+
_defineProperty(ParticleUtil, "childLayoutTargets", new Set(["x", "y", "width", "height"]));
|
|
315
|
+
_defineProperty(ParticleUtil, "gpuChildrenTargets", new Set(["addChildren", "children"]));
|
|
316
|
+
_defineProperty(ParticleUtil, "transientRuntimeFields", new Set(["particleRenderer", "childHandles", "particleValuesDirty", "particleRenderRequested", "pendingGpuChildren", "layoutEpoch", "completeLayoutEpoch", "completeChildrenLayoutState", "layoutCompleteWaiters", "particleSyncPromise", "restoringParticleRuntime"]));
|
|
317
|
+
export { ParticleUtil };
|
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) {
|
|
@@ -129,26 +147,37 @@ var StateManager = /*#__PURE__*/function () {
|
|
|
129
147
|
$pageDom = TModelUtil.getPageDom();
|
|
130
148
|
$pageDom.innerHTML(checkpoint.html);
|
|
131
149
|
TModelUtil.restoreDomState($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
164
|
TModelUtil.restoreDomState($restoredPageDom, checkpoint.domState);
|
|
144
|
-
_context2.next =
|
|
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
|
}
|
|
@@ -250,11 +279,123 @@ 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: "captureGpuVisuals",
|
|
286
|
+
value: function () {
|
|
287
|
+
var _captureGpuVisuals = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
288
|
+
var visuals, _i, _Object$values, tmodel, renderer, canvas, rect, bitmap;
|
|
289
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
290
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
291
|
+
case 0:
|
|
292
|
+
visuals = {};
|
|
293
|
+
_i = 0, _Object$values = Object.values(App.tmodelIdMap);
|
|
294
|
+
case 2:
|
|
295
|
+
if (!(_i < _Object$values.length)) {
|
|
296
|
+
_context3.next = 18;
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
tmodel = _Object$values[_i];
|
|
300
|
+
renderer = tmodel.particleRenderer;
|
|
301
|
+
canvas = renderer === null || renderer === void 0 ? void 0 : renderer.canvas;
|
|
302
|
+
if (!(!canvas || !tmodel.gpuChildrenEnabled)) {
|
|
303
|
+
_context3.next = 8;
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
return _context3.abrupt("continue", 15);
|
|
307
|
+
case 8:
|
|
308
|
+
rect = canvas.getBoundingClientRect();
|
|
309
|
+
_context3.next = 11;
|
|
310
|
+
return renderer.captureBitmap();
|
|
311
|
+
case 11:
|
|
312
|
+
bitmap = _context3.sent;
|
|
313
|
+
if (bitmap) {
|
|
314
|
+
_context3.next = 14;
|
|
315
|
+
break;
|
|
316
|
+
}
|
|
317
|
+
return _context3.abrupt("continue", 15);
|
|
318
|
+
case 14:
|
|
319
|
+
visuals[tmodel.oid] = {
|
|
320
|
+
bitmap: bitmap,
|
|
321
|
+
left: rect.left,
|
|
322
|
+
top: rect.top,
|
|
323
|
+
width: rect.width,
|
|
324
|
+
height: rect.height
|
|
325
|
+
};
|
|
326
|
+
case 15:
|
|
327
|
+
_i++;
|
|
328
|
+
_context3.next = 2;
|
|
329
|
+
break;
|
|
330
|
+
case 18:
|
|
331
|
+
return _context3.abrupt("return", visuals);
|
|
332
|
+
case 19:
|
|
333
|
+
case "end":
|
|
334
|
+
return _context3.stop();
|
|
335
|
+
}
|
|
336
|
+
}, _callee3);
|
|
337
|
+
}));
|
|
338
|
+
function captureGpuVisuals() {
|
|
339
|
+
return _captureGpuVisuals.apply(this, arguments);
|
|
340
|
+
}
|
|
341
|
+
return captureGpuVisuals;
|
|
342
|
+
}()
|
|
343
|
+
}, {
|
|
344
|
+
key: "showGpuRestoreVisuals",
|
|
345
|
+
value: function showGpuRestoreVisuals(visuals) {
|
|
346
|
+
this.hideGpuRestoreVisuals();
|
|
347
|
+
if (!Object.keys(visuals || {}).length) {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
var overlay = document.createElement("div");
|
|
351
|
+
overlay.setAttribute("data-targetjs-gpu-restore-overlay", "true");
|
|
352
|
+
Object.assign(overlay.style, {
|
|
353
|
+
position: "fixed",
|
|
354
|
+
left: "0px",
|
|
355
|
+
top: "0px",
|
|
356
|
+
width: "100vw",
|
|
357
|
+
height: "100vh",
|
|
358
|
+
pointerEvents: "none",
|
|
359
|
+
zIndex: "2147483647"
|
|
360
|
+
});
|
|
361
|
+
for (var _i2 = 0, _Object$values2 = Object.values(visuals); _i2 < _Object$values2.length; _i2++) {
|
|
362
|
+
var visual = _Object$values2[_i2];
|
|
363
|
+
if (!(visual !== null && visual !== void 0 && visual.bitmap)) {
|
|
364
|
+
continue;
|
|
365
|
+
}
|
|
366
|
+
var preview = document.createElement("canvas");
|
|
367
|
+
preview.width = visual.bitmap.width;
|
|
368
|
+
preview.height = visual.bitmap.height;
|
|
369
|
+
Object.assign(preview.style, {
|
|
370
|
+
position: "absolute",
|
|
371
|
+
left: "".concat(visual.left, "px"),
|
|
372
|
+
top: "".concat(visual.top, "px"),
|
|
373
|
+
width: "".concat(visual.width, "px"),
|
|
374
|
+
height: "".concat(visual.height, "px"),
|
|
375
|
+
display: "block"
|
|
376
|
+
});
|
|
377
|
+
var context = preview.getContext("2d");
|
|
378
|
+
context.drawImage(visual.bitmap, 0, 0);
|
|
379
|
+
overlay.appendChild(preview);
|
|
380
|
+
}
|
|
381
|
+
document.body.appendChild(overlay);
|
|
382
|
+
return overlay;
|
|
383
|
+
}
|
|
384
|
+
}, {
|
|
385
|
+
key: "hideGpuRestoreVisuals",
|
|
386
|
+
value: function hideGpuRestoreVisuals() {
|
|
387
|
+
var _document$querySelect;
|
|
388
|
+
(_document$querySelect = document.querySelector('[data-targetjs-gpu-restore-overlay="true"]')) === null || _document$querySelect === void 0 || _document$querySelect.remove();
|
|
389
|
+
}
|
|
390
|
+
}, {
|
|
391
|
+
key: "releaseGpuVisuals",
|
|
392
|
+
value: function releaseGpuVisuals(checkpoint) {
|
|
393
|
+
for (var _i3 = 0, _Object$values3 = Object.values((checkpoint === null || checkpoint === void 0 ? void 0 : checkpoint.gpuVisuals) || {}); _i3 < _Object$values3.length; _i3++) {
|
|
394
|
+
var _visual$bitmap, _visual$bitmap$close, _visual$bitmap2;
|
|
395
|
+
var visual = _Object$values3[_i3];
|
|
396
|
+
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);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
258
399
|
}, {
|
|
259
400
|
key: "has",
|
|
260
401
|
value: function has() {
|
|
@@ -277,15 +418,21 @@ var StateManager = /*#__PURE__*/function () {
|
|
|
277
418
|
key: "clear",
|
|
278
419
|
value: function clear() {
|
|
279
420
|
var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "default";
|
|
280
|
-
|
|
421
|
+
var checkpoint = this.stateCheckpoints[key];
|
|
422
|
+
if (!checkpoint) {
|
|
281
423
|
return false;
|
|
282
424
|
}
|
|
425
|
+
this.releaseGpuVisuals(checkpoint);
|
|
283
426
|
delete this.stateCheckpoints[key];
|
|
284
427
|
return true;
|
|
285
428
|
}
|
|
286
429
|
}, {
|
|
287
430
|
key: "clearAll",
|
|
288
431
|
value: function clearAll() {
|
|
432
|
+
for (var _i4 = 0, _Object$values4 = Object.values(this.stateCheckpoints); _i4 < _Object$values4.length; _i4++) {
|
|
433
|
+
var checkpoint = _Object$values4[_i4];
|
|
434
|
+
this.releaseGpuVisuals(checkpoint);
|
|
435
|
+
}
|
|
289
436
|
this.stateCheckpoints = {};
|
|
290
437
|
}
|
|
291
438
|
}]);
|