targetj 1.0.260 → 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.
@@ -14,7 +14,6 @@ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r),
14
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
15
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
16
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
17
  import { TargetParser } from "./TargetParser.js";
19
18
  import { TargetUtil } from "./TargetUtil.js";
20
19
  import { TUtil } from "./TUtil.js";
@@ -23,35 +22,34 @@ var ParticleUtil = /*#__PURE__*/function () {
23
22
  _classCallCheck(this, ParticleUtil);
24
23
  }
25
24
  return _createClass(ParticleUtil, null, [{
26
- key: "isGpuChildrenTarget",
27
- value: function isGpuChildrenTarget(key) {
28
- return ParticleUtil.gpuChildrenTargets.has(TargetUtil.getTargetName(key));
25
+ key: "affectsChildLayout",
26
+ value: function affectsChildLayout(key) {
27
+ return ["x", "y", "width", "height"].includes(ParticleUtil.getTargetName(key));
29
28
  }
30
29
  }, {
31
- key: "getGpuRenderTargetName",
32
- value: function getGpuRenderTargetName(key) {
33
- var cleanKey = TargetUtil.getTargetName(key);
34
- return ParticleUtil.gpuRenderAliases[cleanKey] || cleanKey;
30
+ key: "affectsChildFlowLayout",
31
+ value: function affectsChildFlowLayout(key) {
32
+ return ["width", "height"].includes(ParticleUtil.getTargetName(key));
35
33
  }
36
34
  }, {
37
- key: "isGpuRenderTarget",
38
- value: function isGpuRenderTarget(key) {
39
- return ParticleUtil.gpuRenderTargets.has(ParticleUtil.getGpuRenderTargetName(key));
35
+ key: "isChildrenTarget",
36
+ value: function isChildrenTarget(key) {
37
+ return ParticleUtil.childrenTargets.has(TargetUtil.getTargetName(key));
40
38
  }
41
39
  }, {
42
- key: "isIgnoredGpuStyleTarget",
43
- value: function isIgnoredGpuStyleTarget(key) {
40
+ key: "getTargetName",
41
+ value: function getTargetName(key) {
44
42
  var cleanKey = TargetUtil.getTargetName(key);
45
- return TargetData.styleSet.has(cleanKey) && !ParticleUtil.isGpuRenderTarget(cleanKey);
43
+ return ParticleUtil.gpuRenderAliases[cleanKey] || cleanKey;
46
44
  }
47
45
  }, {
48
- key: "affectsChildLayout",
49
- value: function affectsChildLayout(key) {
50
- return ParticleUtil.childLayoutTargets.has(ParticleUtil.getGpuRenderTargetName(key));
46
+ key: "isGpuTarget",
47
+ value: function isGpuTarget(key) {
48
+ return ParticleUtil.gpuRenderTargets.has(ParticleUtil.getTargetName(key));
51
49
  }
52
50
  }, {
53
- key: "getGpuTargetMode",
54
- value: function getGpuTargetMode(key) {
51
+ key: "getTargetMode",
52
+ value: function getTargetMode(key) {
55
53
  if (key.endsWith("$$")) {
56
54
  return "deferred";
57
55
  }
@@ -60,55 +58,40 @@ var ParticleUtil = /*#__PURE__*/function () {
60
58
  }
61
59
  return "immediate";
62
60
  }
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
61
  }, {
82
62
  key: "isTransientRuntimeField",
83
63
  value: function isTransientRuntimeField(key) {
84
64
  return ParticleUtil.transientRuntimeFields.has(key);
85
65
  }
86
66
  }, {
87
- key: "isFunctionBasedGpuValue",
88
- value: function isFunctionBasedGpuValue(value) {
89
- if (typeof value === "function") {
67
+ key: "isFunctionBasedTarget",
68
+ value: function isFunctionBasedTarget(target) {
69
+ if (typeof target === "function") {
90
70
  return true;
91
71
  }
92
- return TargetParser.isTargetSpecObject(value) && typeof value.value === "function";
72
+ return TargetParser.isTargetSpecObject(target) && typeof target.value === "function";
93
73
  }
94
74
  }, {
95
- key: "resolveGpuRenderValue",
96
- value: function resolveGpuRenderValue(value, child) {
97
- if (typeof value === "function") {
98
- return value.call(child);
75
+ key: "resolveValue",
76
+ value: function resolveValue(target, child) {
77
+ if (typeof target === "function") {
78
+ return ParticleUtil.resolveValue(target.call(child), child);
99
79
  }
100
- if (!TargetParser.isTargetSpecObject(value)) {
101
- return value;
80
+ if (!TargetParser.isTargetSpecObject(target)) {
81
+ return target;
102
82
  }
103
- var resolved = _objectSpread({}, value);
83
+ var resolved = _objectSpread({}, target);
104
84
  if (typeof resolved.value === "function") {
105
- resolved.value = resolved.value.call(child);
85
+ resolved.value = ParticleUtil.resolveValue(resolved.value.call(child), child);
106
86
  }
107
87
  return resolved;
108
88
  }
109
89
  }, {
110
- key: "getGpuInitialRenderValue",
111
- value: function getGpuInitialRenderValue(value) {
90
+ key: "getInitialValue",
91
+ value: function getInitialValue(value) {
92
+ if (TargetParser.isValueStepsCycleArray(value)) {
93
+ return value[0];
94
+ }
112
95
  if (!TargetParser.isTargetSpecObject(value)) {
113
96
  return value;
114
97
  }
@@ -118,113 +101,56 @@ var ParticleUtil = /*#__PURE__*/function () {
118
101
  return value.value;
119
102
  }
120
103
  }, {
121
- key: "setGpuInitialChildValue",
122
- value: function setGpuInitialChildValue(child, key, value) {
104
+ key: "setInitialValue",
105
+ value: function setInitialValue(child, key, value) {
123
106
  if (!child || !TUtil.isDefined(value)) {
124
107
  return;
125
108
  }
126
109
  child.val(key, value);
127
110
  }
128
111
  }, {
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") {
112
+ key: "requiresRuntime",
113
+ value: function requiresRuntime(key, target) {
114
+ var mode = ParticleUtil.getTargetMode(key);
115
+ if (!ParticleUtil.isGpuTarget(key) || TargetParser.isIntervalTarget(target)) {
147
116
  return true;
148
117
  }
149
118
  if (mode !== "immediate") {
150
119
  return true;
151
120
  }
152
- if (!ParticleUtil.isGpuRenderTarget(key)) {
153
- return false;
121
+ if (TargetParser.isValueStepsCycleArray(target)) {
122
+ return true;
154
123
  }
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") {
124
+ if (!TargetParser.isTargetSpecObject(target)) {
161
125
  return false;
162
126
  }
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);
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);
181
128
  }
182
129
  }, {
183
- key: "compileGpuChildDefinition",
184
- value: function compileGpuChildDefinition(child, definition) {
130
+ key: "compileChildDefinition",
131
+ value: function compileChildDefinition(child, definition) {
185
132
  var renderDefinition = {};
186
133
  var runtimeTargets = [];
187
- var ignoredStyles = [];
188
- var layoutFunctions = [];
189
134
  var entries = Object.entries(definition).map(function (_ref) {
190
135
  var _ref2 = _slicedToArray(_ref, 2),
191
136
  key = _ref2[0],
192
- value = _ref2[1];
137
+ target = _ref2[1];
193
138
  return {
194
139
  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)
140
+ target: target,
141
+ mode: ParticleUtil.getTargetMode(key),
142
+ targetName: ParticleUtil.getTargetName(key),
143
+ requiresRuntime: ParticleUtil.requiresRuntime(key, target)
200
144
  };
201
145
  });
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
146
  var _iterator = _createForOfIteratorHelper(entries),
209
147
  _step;
210
148
  try {
211
149
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
212
150
  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));
151
+ var cleanKey = TargetUtil.getTargetName(entry.key);
152
+ child.allTargetMap[cleanKey] = entry.key;
219
153
  }
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
154
  } catch (err) {
229
155
  _iterator.e(err);
230
156
  } finally {
@@ -235,24 +161,16 @@ var ParticleUtil = /*#__PURE__*/function () {
235
161
  try {
236
162
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
237
163
  var _entry = _step2.value;
238
- if (_entry.kind !== "render" || _entry.mode !== "immediate" || _entry.requiresRuntime || !ParticleUtil.isFunctionBasedGpuValue(_entry.value)) {
164
+ if (_entry.mode !== "immediate" || ParticleUtil.isFunctionBasedTarget(_entry.target)) {
239
165
  continue;
240
166
  }
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
- });
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;
250
172
  }
251
173
  }
252
-
253
- /*
254
- * Preserve runtime targets in their original code order.
255
- */
256
174
  } catch (err) {
257
175
  _iterator2.e(err);
258
176
  } finally {
@@ -263,34 +181,34 @@ var ParticleUtil = /*#__PURE__*/function () {
263
181
  try {
264
182
  for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
265
183
  var _entry2 = _step3.value;
266
- if (_entry2.kind === "ignoredStyle") {
267
- ignoredStyles.push(_entry2.key);
184
+ if (_entry2.mode !== "immediate" || !ParticleUtil.isGpuTarget(_entry2.key) || !ParticleUtil.isFunctionBasedTarget(_entry2.target)) {
268
185
  continue;
269
186
  }
270
- if (!_entry2.requiresRuntime) {
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
+ }
271
195
  continue;
272
196
  }
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);
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
+ });
294
212
  }
295
213
  }
296
214
  } catch (err) {
@@ -298,20 +216,50 @@ var ParticleUtil = /*#__PURE__*/function () {
298
216
  } finally {
299
217
  _iterator3.f();
300
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
+ }
301
252
  return {
302
253
  renderDefinition: renderDefinition,
303
- runtimeTargets: runtimeTargets,
304
- ignoredStyles: ignoredStyles,
305
- layoutFunctions: layoutFunctions
254
+ runtimeTargets: runtimeTargets
306
255
  };
307
256
  }
308
257
  }]);
309
258
  }();
310
- _defineProperty(ParticleUtil, "gpuRenderTargets", new Set(["x", "y", "width", "height", "borderRadius", "backgroundColor", "rotate"]));
259
+ _defineProperty(ParticleUtil, "gpuRenderTargets", new Set(["x", "y", "width", "height", "borderRadius", "backgroundColor", "rotate", "opacity", "scale"]));
311
260
  _defineProperty(ParticleUtil, "gpuRenderAliases", {
312
261
  background: "backgroundColor"
313
262
  });
314
- _defineProperty(ParticleUtil, "childLayoutTargets", new Set(["x", "y", "width", "height"]));
315
- _defineProperty(ParticleUtil, "gpuChildrenTargets", new Set(["addChildren", "children"]));
263
+ _defineProperty(ParticleUtil, "childrenTargets", new Set(["addChildren", "children"]));
316
264
  _defineProperty(ParticleUtil, "transientRuntimeFields", new Set(["particleRenderer", "childHandles", "particleValuesDirty", "particleRenderRequested", "pendingGpuChildren", "layoutEpoch", "completeLayoutEpoch", "completeChildrenLayoutState", "layoutCompleteWaiters", "particleSyncPromise", "restoringParticleRuntime"]));
317
265
  export { ParticleUtil };
@@ -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
- if (newDelay === undefined || manager.lists.activeTModels.length > 0 || manager.lists.updatingTModels.length > 0 || hasImmediateWork) {
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
- } else if (hasImmediateWork) {
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[0];
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);
@@ -146,7 +146,7 @@ var StateManager = /*#__PURE__*/function () {
146
146
  getLoader().restoreRuntimeSnapshot(checkpoint.loaderSnapshot, tmodelIdMap);
147
147
  $pageDom = TModelUtil.getPageDom();
148
148
  $pageDom.innerHTML(checkpoint.html);
149
- TModelUtil.restoreDomState($pageDom, checkpoint.domState);
149
+ TModelUtil.restoreMountedDom($pageDom, checkpoint.domState);
150
150
  this.showGpuRestoreVisuals(checkpoint.gpuVisuals);
151
151
  tApp.tRoot.$dom = TModelUtil.getRootDom();
152
152
  visibleModels = checkpoint.visibleOids.map(function (oid) {
@@ -161,7 +161,7 @@ var StateManager = /*#__PURE__*/function () {
161
161
  return tApp.start();
162
162
  case 31:
163
163
  $restoredPageDom = TModelUtil.getPageDom();
164
- TModelUtil.restoreDomState($restoredPageDom, checkpoint.domState);
164
+ TModelUtil.restoreMountedDom($restoredPageDom, checkpoint.domState);
165
165
  _context2.next = 35;
166
166
  return TModelUtil.restoreScroll(checkpoint);
167
167
  case 35:
@@ -261,8 +261,8 @@ var StateManager = /*#__PURE__*/function () {
261
261
  }, {
262
262
  key: "connectRestoredDoms",
263
263
  value: function connectRestoredDoms(visibleModels, allModels) {
264
- var newVisibles = DomInit.initCacheDoms(visibleModels);
265
- var restoredWithDom = TUtil.uniqueTModels([].concat(_toConsumableArray(visibleModels), _toConsumableArray(newVisibles)));
264
+ var restoredDoms = DomInit.initCacheDoms(visibleModels);
265
+ var restoredWithDom = TUtil.uniqueTModels([].concat(_toConsumableArray(visibleModels), _toConsumableArray(restoredDoms)));
266
266
  this.normalizeRestoredModels(allModels);
267
267
  tApp.manager.visibleOidMap = {};
268
268
  var _iterator4 = _createForOfIteratorHelper(restoredWithDom),
@@ -270,7 +270,7 @@ var StateManager = /*#__PURE__*/function () {
270
270
  try {
271
271
  for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
272
272
  var tmodel = _step4.value;
273
- if (tmodel.isIncluded()) {
273
+ if (tmodel.isIncluded() && tmodel.isVisible()) {
274
274
  tApp.manager.visibleOidMap[tmodel.oid] = tmodel;
275
275
  }
276
276
  }
@@ -281,11 +281,48 @@ var StateManager = /*#__PURE__*/function () {
281
281
  }
282
282
  return restoredWithDom;
283
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
+ }
284
321
  }, {
285
322
  key: "captureGpuVisuals",
286
323
  value: function () {
287
324
  var _captureGpuVisuals = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
288
- var visuals, _i, _Object$values, tmodel, renderer, canvas, rect, bitmap;
325
+ var visuals, _i, _Object$values, tmodel, renderer, canvas, rect, clipRect, bitmap;
289
326
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
290
327
  while (1) switch (_context3.prev = _context3.next) {
291
328
  case 0:
@@ -293,7 +330,7 @@ var StateManager = /*#__PURE__*/function () {
293
330
  _i = 0, _Object$values = Object.values(App.tmodelIdMap);
294
331
  case 2:
295
332
  if (!(_i < _Object$values.length)) {
296
- _context3.next = 18;
333
+ _context3.next = 21;
297
334
  break;
298
335
  }
299
336
  tmodel = _Object$values[_i];
@@ -303,37 +340,48 @@ var StateManager = /*#__PURE__*/function () {
303
340
  _context3.next = 8;
304
341
  break;
305
342
  }
306
- return _context3.abrupt("continue", 15);
343
+ return _context3.abrupt("continue", 18);
307
344
  case 8:
308
345
  rect = canvas.getBoundingClientRect();
309
- _context3.next = 11;
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;
310
354
  return renderer.captureBitmap();
311
- case 11:
355
+ case 14:
312
356
  bitmap = _context3.sent;
313
357
  if (bitmap) {
314
- _context3.next = 14;
358
+ _context3.next = 17;
315
359
  break;
316
360
  }
317
- return _context3.abrupt("continue", 15);
318
- case 14:
361
+ return _context3.abrupt("continue", 18);
362
+ case 17:
319
363
  visuals[tmodel.oid] = {
320
364
  bitmap: bitmap,
321
365
  left: rect.left,
322
366
  top: rect.top,
323
367
  width: rect.width,
324
- height: rect.height
368
+ height: rect.height,
369
+ clipLeft: clipRect.left,
370
+ clipTop: clipRect.top,
371
+ clipWidth: clipRect.width,
372
+ clipHeight: clipRect.height
325
373
  };
326
- case 15:
374
+ case 18:
327
375
  _i++;
328
376
  _context3.next = 2;
329
377
  break;
330
- case 18:
378
+ case 21:
331
379
  return _context3.abrupt("return", visuals);
332
- case 19:
380
+ case 22:
333
381
  case "end":
334
382
  return _context3.stop();
335
383
  }
336
- }, _callee3);
384
+ }, _callee3, this);
337
385
  }));
338
386
  function captureGpuVisuals() {
339
387
  return _captureGpuVisuals.apply(this, arguments);
@@ -360,23 +408,32 @@ var StateManager = /*#__PURE__*/function () {
360
408
  });
361
409
  for (var _i2 = 0, _Object$values2 = Object.values(visuals); _i2 < _Object$values2.length; _i2++) {
362
410
  var visual = _Object$values2[_i2];
363
- if (!(visual !== null && visual !== void 0 && visual.bitmap)) {
411
+ if (!(visual !== null && visual !== void 0 && visual.bitmap) || visual.clipWidth <= 0 || visual.clipHeight <= 0) {
364
412
  continue;
365
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
+ });
366
423
  var preview = document.createElement("canvas");
367
424
  preview.width = visual.bitmap.width;
368
425
  preview.height = visual.bitmap.height;
369
426
  Object.assign(preview.style, {
370
427
  position: "absolute",
371
- left: "".concat(visual.left, "px"),
372
- top: "".concat(visual.top, "px"),
428
+ left: "".concat(visual.left - visual.clipLeft, "px"),
429
+ top: "".concat(visual.top - visual.clipTop, "px"),
373
430
  width: "".concat(visual.width, "px"),
374
431
  height: "".concat(visual.height, "px"),
375
432
  display: "block"
376
433
  });
377
- var context = preview.getContext("2d");
378
- context.drawImage(visual.bitmap, 0, 0);
379
- overlay.appendChild(preview);
434
+ preview.getContext("2d").drawImage(visual.bitmap, 0, 0);
435
+ clip.appendChild(preview);
436
+ overlay.appendChild(clip);
380
437
  }
381
438
  document.body.appendChild(overlay);
382
439
  return overlay;
@@ -24,7 +24,7 @@ var TMODEL_REF_KEY = "__targetjsTModelRef";
24
24
  * These fields are reconstructed separately or must be connected to the
25
25
  * current DOM rather than copied from the old tree.
26
26
  */
27
- var EXCLUDED_RUNTIME_FIELDS = new Set(["_state", "targets", "targetDefinitions", "restoringRuntime", "restoredUsesExistingDom", "type", "oid", "oidNum", "originalId", "parent", "allChildrenList", "allChildrenMap", "$dom", "viewport", "visibilityStatus", "currentStatus", "dirtyLayout", "originWindowEpoch", "hasDomNow", "isNowVisible", "domHeightTimestamp", "domWidthTimestamp", "lastBatch", "waapiBatch", "finalKeyframe", "finalRawFrame"]);
27
+ var EXCLUDED_RUNTIME_FIELDS = new Set(["_state", "targets", "targetDefinitions", "restoringRuntime", "restoredUsesExistingDom", "particleRenderer", "particleRuntime", "particleSyncPromise", "layoutCompleteWaiters", "isPrevTargetUpdated", "type", "oid", "oidNum", "originalId", "parent", "allChildrenList", "allChildrenMap", "$dom", "viewport", "visibilityStatus", "currentStatus", "dirtyLayout", "originWindowEpoch", "hasDomNow", "isNowVisible", "domHeightTimestamp", "domWidthTimestamp", "lastBatch", "waapiBatch", "finalKeyframe", "finalRawFrame"]);
28
28
  var CHILD_OPERATION_FIELDS = ["addedChildren", "deletedChildren", "movedChildren"];
29
29
  var RUNTIME_TIMESTAMP_FIELDS = new Set(["lastUpdate", "scheduleTimeStamp", "completeTime", "creationTime", "activationTime", "catchupAt", "startTime", "lastResizeHandledTime"]);
30
30
  var TARGET_RUNTIME_FIELDS = ["originalTargetName", "originalTModel", "invokerTargetName", "invokerTModel", "fetchAction", "childAction", "addChildAction"];