targetj 1.0.260 → 1.1.1

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.
@@ -1,11 +1,11 @@
1
- function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
2
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
- function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
4
- function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
5
1
  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; } } }; }
6
2
  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; }
7
3
  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; }
8
4
  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; }
5
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
6
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
8
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
9
9
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
10
10
  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."); }
11
11
  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; } }
@@ -36,10 +36,11 @@ import { TModelFactory } from "./TModelFactory.js";
36
36
  import { ParticleRenderer } from "./ParticleRenderer.js";
37
37
  import { ParticleRuntime } from "./ParticleRuntime.js";
38
38
  import { ParticleUtil } from "./ParticleUtil.js";
39
+ import { ParticleChild } from "./ParticleChild.js";
39
40
  import { TargetParser } from "./TargetParser.js";
40
41
  import { TargetUtil } from "./TargetUtil.js";
41
42
  import { TUtil } from "./TUtil.js";
42
- import { Child } from "./Child.js";
43
+ import { getRunScheduler } from "./App.js";
43
44
 
44
45
  /**
45
46
  * It provides a TModel that can render instanced addChildren values on the GPU.
@@ -50,23 +51,21 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
50
51
  var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
51
52
  _classCallCheck(this, ParticleTModel);
52
53
  _this = _callSuper(this, ParticleTModel, [type, targets, oid, options]);
53
- _this.particleValues = [];
54
+ _this.childActualValues = [];
55
+ _this.childTargetMaps = [];
54
56
  _this.particleValuesDirty = false;
55
57
  _this.particleRenderRequested = false;
56
58
  _this.childHandles = [];
57
59
  _this.childTargetValues = {};
58
60
  _this.childTransitions = {};
59
61
  _this.pendingGpuChildren = {};
60
-
61
- /*
62
- * Logical lightweight-child runtime state remains directly on the TModel
63
- * so it can participate in runtime checkpointing.
64
- */
62
+ _this.pendingImperativeCompletions = new Map();
65
63
  _this.childRuntimePrograms = [];
66
64
  _this.childRuntimeStates = [];
67
65
  _this.pendingGpuChildRuntimeCounts = {};
68
66
  _this.activeChildTransitionKey = undefined;
69
67
  _this.gpuChildrenEnabled = false;
68
+ _this.childGeneration = 0;
70
69
  _this.layoutEpoch = 0;
71
70
  _this.completeLayoutEpoch = -1;
72
71
  _this.layoutCompleteWaiters = [];
@@ -78,9 +77,10 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
78
77
  }
79
78
  _inherits(ParticleTModel, _TModel);
80
79
  return _createClass(ParticleTModel, [{
81
- key: "onDomReady",
80
+ key: "onDomAvailable",
82
81
  value: function () {
83
- var _onDomReady = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
82
+ var _onDomAvailable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
83
+ var ready;
84
84
  return _regeneratorRuntime().wrap(function _callee$(_context) {
85
85
  while (1) switch (_context.prev = _context.next) {
86
86
  case 0:
@@ -93,22 +93,25 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
93
93
  _context.next = 4;
94
94
  return this.syncParticleRenderer();
95
95
  case 4:
96
- this.particleRuntime.markPendingRenderReady();
97
- case 5:
96
+ ready = _context.sent;
97
+ if (ready) {
98
+ this.particleRuntime.markPendingRenderReady();
99
+ }
100
+ case 6:
98
101
  case "end":
99
102
  return _context.stop();
100
103
  }
101
104
  }, _callee, this);
102
105
  }));
103
- function onDomReady() {
104
- return _onDomReady.apply(this, arguments);
106
+ function onDomAvailable() {
107
+ return _onDomAvailable.apply(this, arguments);
105
108
  }
106
- return onDomReady;
109
+ return onDomAvailable;
107
110
  }()
108
111
  }, {
109
112
  key: "restoreRuntimeDomDerivedState",
110
113
  value: function () {
111
- var _restoreRuntimeDomDerivedState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
114
+ var _restoreRuntimeDomDerivedState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(explodeSource) {
112
115
  var restored;
113
116
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
114
117
  while (1) switch (_context2.prev = _context2.next) {
@@ -135,28 +138,62 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
135
138
  }
136
139
  return _context2.abrupt("return", false);
137
140
  case 12:
138
- _context2.next = 14;
139
- return this.particleRenderer.waitForPresentedFrame();
140
- case 14:
141
- _context2.prev = 14;
142
- this.restoringParticleRuntime = false;
143
- return _context2.finish(14);
144
- case 17:
141
+ if (!this.explodeChildrenState) {
142
+ _context2.next = 18;
143
+ break;
144
+ }
145
+ _context2.next = 15;
146
+ return this.restoreExplodeTexture(explodeSource);
147
+ case 15:
148
+ restored = _context2.sent;
145
149
  if (restored) {
146
- this.particleRuntime.resumeRestored();
150
+ _context2.next = 18;
151
+ break;
147
152
  }
153
+ return _context2.abrupt("return", false);
154
+ case 18:
155
+ this.particleRuntime.markRenderReady(this.childHandles.map(function (child) {
156
+ return child.index;
157
+ }));
158
+ _context2.next = 21;
159
+ return this.particleRenderer.waitForPresentedFrame();
160
+ case 21:
161
+ _context2.prev = 21;
162
+ this.restoringParticleRuntime = false;
163
+ return _context2.finish(21);
164
+ case 24:
148
165
  return _context2.abrupt("return", restored);
149
- case 19:
166
+ case 25:
150
167
  case "end":
151
168
  return _context2.stop();
152
169
  }
153
- }, _callee2, this, [[4,, 14, 17]]);
170
+ }, _callee2, this, [[4,, 21, 24]]);
154
171
  }));
155
- function restoreRuntimeDomDerivedState() {
172
+ function restoreRuntimeDomDerivedState(_x) {
156
173
  return _restoreRuntimeDomDerivedState.apply(this, arguments);
157
174
  }
158
175
  return restoreRuntimeDomDerivedState;
159
176
  }()
177
+ }, {
178
+ key: "restoreExplodeTexture",
179
+ value: function restoreExplodeTexture(explodeSource) {
180
+ if (!this.explodeChildrenState) {
181
+ return Promise.resolve(true);
182
+ }
183
+ if (!explodeSource) {
184
+ return Promise.resolve(false);
185
+ }
186
+ return this.particleRenderer.setExplodeSource({
187
+ bitmap: explodeSource
188
+ });
189
+ }
190
+ }, {
191
+ key: "disposeRuntimeDerivedState",
192
+ value: function disposeRuntimeDerivedState() {
193
+ var _this$particleRuntime, _this$particleRendere;
194
+ (_this$particleRuntime = this.particleRuntime) === null || _this$particleRuntime === void 0 || _this$particleRuntime.dispose();
195
+ (_this$particleRendere = this.particleRenderer) === null || _this$particleRendere === void 0 || _this$particleRendere.destroy();
196
+ }
160
197
  }, {
161
198
  key: "syncParticleRenderer",
162
199
  value: function syncParticleRenderer() {
@@ -173,7 +210,7 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
173
210
  key: "syncParticleRendererNow",
174
211
  value: function () {
175
212
  var _syncParticleRendererNow = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
176
- var key, targetName, transition;
213
+ var key, targetName, transition, applied;
177
214
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
178
215
  while (1) switch (_context3.prev = _context3.next) {
179
216
  case 0:
@@ -183,12 +220,12 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
183
220
  }
184
221
  return _context3.abrupt("return", false);
185
222
  case 2:
186
- if (!this.particleValues.length) {
223
+ if (!this.childHandles.length) {
187
224
  _context3.next = 7;
188
225
  break;
189
226
  }
190
227
  _context3.next = 5;
191
- return this.particleRenderer.setParticles(this.particleValues);
228
+ return this.particleRenderer.setParticles(this.childHandles);
192
229
  case 5:
193
230
  _context3.next = 9;
194
231
  break;
@@ -212,11 +249,14 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
212
249
  return _context3.abrupt("return", true);
213
250
  case 16:
214
251
  _context3.next = 18;
215
- return this.particleRenderer.setTargetParticles(transition.values, transition.steps);
252
+ return this.particleRenderer.setTargetParticles(transition.values, transition.steps, transition.generation);
216
253
  case 18:
217
- this.handleSpecialTargetStep(key);
254
+ applied = _context3.sent;
255
+ if (applied && this.childTransitions[targetName] === transition) {
256
+ this.handleSpecialTargetStep(key);
257
+ }
218
258
  return _context3.abrupt("return", true);
219
- case 20:
259
+ case 21:
220
260
  case "end":
221
261
  return _context3.stop();
222
262
  }
@@ -231,20 +271,39 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
231
271
  key: "requestParticleRender",
232
272
  value: function requestParticleRender() {
233
273
  var _this3 = this;
234
- if (this.restoringParticleRuntime || !this.gpuChildrenEnabled || !this.hasDom() || this.particleRenderRequested) {
274
+ if (this.restoringParticleRuntime || !this.gpuChildrenEnabled || !this.isVisible() || !this.hasDom() || this.particleRenderRequested) {
235
275
  return;
236
276
  }
237
277
  this.particleRenderRequested = true;
238
278
  requestAnimationFrame(function () {
239
279
  _this3.particleRenderRequested = false;
280
+ if (!_this3.isVisible() || !_this3.hasDom()) {
281
+ return;
282
+ }
283
+ if (_this3.activeChildTransitionKey) {
284
+ _this3.particleRenderer.render();
285
+ return;
286
+ }
240
287
  if (_this3.particleValuesDirty) {
241
288
  _this3.particleValuesDirty = false;
242
- _this3.particleRenderer.updateParticles(_this3.particleValues);
289
+ _this3.particleRenderer.updateParticles(_this3.childHandles);
243
290
  } else {
244
291
  _this3.particleRenderer.render();
245
292
  }
246
293
  });
247
294
  }
295
+ }, {
296
+ key: "onVisibilityChange",
297
+ value: function onVisibilityChange(visible) {
298
+ if (this.restoringParticleRuntime) {
299
+ return;
300
+ }
301
+ if (visible) {
302
+ this.particleRuntime.resumeForVisibility();
303
+ } else {
304
+ this.particleRuntime.pauseForVisibility();
305
+ }
306
+ }
248
307
  }, {
249
308
  key: "getChildrenRenderer",
250
309
  value: function getChildrenRenderer() {
@@ -265,7 +324,7 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
265
324
  key = _ref2[0],
266
325
  propertyValue = _ref2[1];
267
326
  var cleanKey = TargetUtil.getTargetName(key);
268
- return key === cleanKey && _this4.supportsChildTarget(cleanKey) && _this4.canRenderChildValue(propertyValue);
327
+ return key === cleanKey && ParticleUtil.isGpuTarget(cleanKey) && _this4.canRenderChildValue(propertyValue);
269
328
  });
270
329
  });
271
330
  }
@@ -286,11 +345,6 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
286
345
  }
287
346
  return true;
288
347
  }
289
- }, {
290
- key: "supportsChildTarget",
291
- value: function supportsChildTarget(key) {
292
- return ParticleUtil.isGpuRenderTarget(key);
293
- }
294
348
  }, {
295
349
  key: "affectsChildLayout",
296
350
  value: function affectsChildLayout(key) {
@@ -307,71 +361,83 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
307
361
  }, {
308
362
  key: "getChildren",
309
363
  value: function getChildren() {
310
- if (!this.gpuChildrenEnabled) {
311
- return _superPropGet(ParticleTModel, "getChildren", this, 3)([]);
312
- }
313
- return this.childHandles;
364
+ var children = _superPropGet(ParticleTModel, "getChildren", this, 3)([]);
365
+ return this.gpuChildrenEnabled ? [].concat(_toConsumableArray(children), _toConsumableArray(this.childHandles)) : children;
314
366
  }
315
367
  }, {
316
368
  key: "getChildValue",
317
369
  value: function getChildValue(index, key) {
318
- var _this$particleValues$;
319
- return (_this$particleValues$ = this.particleValues[index]) === null || _this$particleValues$ === void 0 ? void 0 : _this$particleValues$[TargetUtil.getTargetName(key)];
370
+ var child = this.childHandles[index];
371
+ if (!child) {
372
+ return;
373
+ }
374
+ var cleanKey = ParticleUtil.getTargetName(key);
375
+ if ((cleanKey === "x" || cleanKey === "y") && !child.allTargetMap[cleanKey]) {
376
+ return child[cleanKey];
377
+ }
378
+ return child.actualValues[cleanKey];
320
379
  }
321
380
  }, {
322
381
  key: "setChildTarget",
323
- value: function setChildTarget(index, key, target) {
324
- var _this$childTargetValu, _this$childTargetValu2, _targetValues$index;
325
- var targetName = TargetUtil.getTargetName(TargetUtil.currentTargetName);
326
- var cleanKey = TargetUtil.getTargetName(key);
327
- if (!targetName) {
382
+ value: function setChildTarget(index, key, target, steps, interval, easing) {
383
+ var _this$targetValues$or;
384
+ var originalTargetName = TargetUtil.currentTargetName;
385
+ var originalTModel = TargetUtil.currentTModel;
386
+ var cleanKey = ParticleUtil.getTargetName(key);
387
+ var child = this.childHandles[index];
388
+ if (!child) {
328
389
  return;
329
390
  }
330
- if (key !== cleanKey || !this.supportsChildTarget(cleanKey)) {
331
- throw new Error("GPU child target \"".concat(key, "\" is not supported yet."));
391
+ if (originalTModel && originalTargetName && originalTModel !== this) {
392
+ TargetUtil.markChildAction(originalTModel, originalTargetName, child);
332
393
  }
333
- var targetValues = (_this$childTargetValu2 = (_this$childTargetValu = this.childTargetValues)[targetName]) !== null && _this$childTargetValu2 !== void 0 ? _this$childTargetValu2 : _this$childTargetValu[targetName] = [];
334
- var childValues = (_targetValues$index = targetValues[index]) !== null && _targetValues$index !== void 0 ? _targetValues$index : targetValues[index] = {};
335
- childValues[cleanKey] = TargetParser.isTargetSpecObject(target) ? _objectSpread({}, target) : {
336
- value: target
337
- };
394
+ child.allTargetMap[cleanKey] = key;
395
+ this.childTargetMaps[index] = child.allTargetMap;
396
+
397
+ // Collect imperative assignments issued synchronously by a sequential parent target.
398
+ // TargetExecutor calls handleSpecialTarget() after evaluating the parent function.
399
+ if (originalTModel === this && typeof originalTargetName === "string" && originalTargetName.endsWith("$$") && this.targets[originalTargetName] && ((_this$targetValues$or = this.targetValues[originalTargetName]) === null || _this$targetValues$or === void 0 ? void 0 : _this$targetValues$or.status) !== "done") {
400
+ var _this$childTargetValu, _this$childTargetValu2, _targetValues$index;
401
+ var targetName = TargetUtil.getTargetName(originalTargetName);
402
+ var targetValues = (_this$childTargetValu2 = (_this$childTargetValu = this.childTargetValues)[targetName]) !== null && _this$childTargetValu2 !== void 0 ? _this$childTargetValu2 : _this$childTargetValu[targetName] = [];
403
+ var childTargets = (_targetValues$index = targetValues[index]) !== null && _targetValues$index !== void 0 ? _targetValues$index : targetValues[index] = {};
404
+ var specification = TargetParser.isTargetSpecObject(target) ? _objectSpread({}, target) : {
405
+ value: target
406
+ };
407
+ if (specification.steps === undefined && steps !== undefined) {
408
+ specification.steps = steps;
409
+ }
410
+ if (specification.interval === undefined && interval !== undefined) {
411
+ specification.interval = interval;
412
+ }
413
+ if (specification.easing === undefined && easing !== undefined) {
414
+ specification.easing = easing;
415
+ }
416
+ childTargets[cleanKey] = specification;
417
+ return;
418
+ }
419
+ this.particleRuntime.setImperativeTarget(index, cleanKey, target, steps, interval, easing, originalTargetName, originalTModel);
338
420
  }
339
421
  }, {
340
422
  key: "setChildValue",
341
423
  value: function setChildValue(index, key, value) {
342
- var cleanKey = TargetUtil.getTargetName(key);
343
- var childValues = this.particleValues[index];
344
- if (!childValues || childValues[cleanKey] === value) {
345
- return;
346
- }
347
- childValues[cleanKey] = value;
348
- this.particleValuesDirty = true;
349
- if (this.affectsChildLayout(cleanKey)) {
350
- this.invalidateChildrenLayout();
351
- }
424
+ var invalidateLayout = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
352
425
  var child = this.childHandles[index];
353
- if (child) {
354
- child.actualValues[cleanKey] = value;
426
+ if (!child) {
427
+ return false;
355
428
  }
356
- }
357
- }, {
358
- key: "setChildLayoutValue",
359
- value: function setChildLayoutValue(index, key, value) {
360
- var _this$getScrollLeft, _this$getScrollTop;
361
- var childValues = this.particleValues[index];
362
- if (!childValues) {
363
- return;
429
+ var cleanKey = ParticleUtil.getTargetName(key);
430
+ if (child.actualValues[cleanKey] === value) {
431
+ return false;
364
432
  }
365
- if (this.particleRuntime.isControlled(index, key)) {
366
- return;
433
+ child.actualValues[cleanKey] = value;
434
+ if (ParticleUtil.isGpuTarget(cleanKey)) {
435
+ this.particleValuesDirty = true;
367
436
  }
368
- var scrollOffset = key === "x" ? (_this$getScrollLeft = this.getScrollLeft()) !== null && _this$getScrollLeft !== void 0 ? _this$getScrollLeft : 0 : key === "y" ? (_this$getScrollTop = this.getScrollTop()) !== null && _this$getScrollTop !== void 0 ? _this$getScrollTop : 0 : 0;
369
- var layoutValue = value + scrollOffset;
370
- if (childValues[key] === layoutValue) {
371
- return;
437
+ if (invalidateLayout && this.affectsChildLayout(cleanKey)) {
438
+ this.invalidateLayout();
372
439
  }
373
- childValues[key] = layoutValue;
374
- this.particleValuesDirty = true;
440
+ return true;
375
441
  }
376
442
  }, {
377
443
  key: "getChildTargetValues",
@@ -384,80 +450,200 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
384
450
  var _this5 = this;
385
451
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
386
452
  var targetName = TargetUtil.getTargetName(key);
387
- var values = new Array(this.particleValues.length);
388
- var steps = new Array(this.particleValues.length);
389
453
  var defaultSteps = Math.max(0, Number(options.steps) || 0);
390
- var maxSteps = defaultSteps;
391
- for (var index = 0; index < this.particleValues.length; index++) {
392
- var particle = this.particleValues[index];
454
+ var children = [];
455
+ var handledNonGpu = false;
456
+ for (var index = 0; index < targetValues.length; index++) {
393
457
  var targets = targetValues[index];
394
- var nextParticle = _objectSpread({}, particle);
395
- var childSteps = {};
396
- if (targets) {
397
- for (var _i = 0, _Object$entries = Object.entries(targets); _i < _Object$entries.length; _i++) {
398
- var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
399
- property = _Object$entries$_i[0],
400
- rawTarget = _Object$entries$_i[1];
401
- var target = TargetParser.isTargetSpecObject(rawTarget) ? rawTarget : {
402
- value: rawTarget
403
- };
404
- nextParticle[property] = target.value;
405
- var propertySteps = target.steps !== undefined ? Math.max(0, Number(target.steps) || 0) : defaultSteps;
406
- childSteps[property] = propertySteps;
407
- maxSteps = Math.max(maxSteps, propertySteps);
458
+ var child = this.childHandles[index];
459
+ if (!targets || !child) {
460
+ continue;
461
+ }
462
+ var transitionChild = {
463
+ index: index,
464
+ target: {},
465
+ steps: {},
466
+ loops: {},
467
+ valueLists: {}
468
+ };
469
+ for (var _i = 0, _Object$entries = Object.entries(targets); _i < _Object$entries.length; _i++) {
470
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
471
+ property = _Object$entries$_i[0],
472
+ rawTarget = _Object$entries$_i[1];
473
+ var targetProperty = ParticleUtil.getTargetName(property);
474
+ if (!ParticleUtil.isGpuTarget(targetProperty)) {
475
+ var _TargetParser$getValu = TargetParser.getValueStepsCycles(child, targetProperty, rawTarget, 0),
476
+ _TargetParser$getValu2 = _slicedToArray(_TargetParser$getValu, 2),
477
+ _value = _TargetParser$getValu2[0],
478
+ steps = _TargetParser$getValu2[1];
479
+ if (!steps) {
480
+ this.setChildValue(index, targetProperty, _value);
481
+ handledNonGpu = true;
482
+ }
483
+ continue;
408
484
  }
485
+ var _TargetParser$getValu3 = TargetParser.getValueStepsCycles(child, targetProperty, rawTarget, 0),
486
+ _TargetParser$getValu4 = _slicedToArray(_TargetParser$getValu3, 2),
487
+ value = _TargetParser$getValu4[0],
488
+ parsedSteps = _TargetParser$getValu4[1];
489
+ var hasOwnSteps = TUtil.isDefined(rawTarget === null || rawTarget === void 0 ? void 0 : rawTarget.steps) || TargetParser.isValueStepsCycleArray(rawTarget === null || rawTarget === void 0 ? void 0 : rawTarget.value);
490
+ var propertySteps = hasOwnSteps ? parsedSteps : defaultSteps;
491
+ if (TargetParser.isListTarget(value)) {
492
+ transitionChild.valueLists[targetProperty] = value.list;
493
+ transitionChild.target[targetProperty] = value.list[1];
494
+ } else {
495
+ transitionChild.target[targetProperty] = value;
496
+ }
497
+ transitionChild.steps[targetProperty] = propertySteps;
498
+ transitionChild.loops[targetProperty] = (rawTarget === null || rawTarget === void 0 ? void 0 : rawTarget.loop) === true;
499
+ }
500
+ if (Object.keys(transitionChild.target).length) {
501
+ children.push(transitionChild);
409
502
  }
410
- values[index] = nextParticle;
411
- steps[index] = childSteps;
412
503
  }
413
- this.childTransitions[targetName] = {
414
- values: values,
415
- steps: steps
504
+ if (!children.length) {
505
+ if (!handledNonGpu) {
506
+ return false;
507
+ }
508
+ delete this.childTargetValues[targetName];
509
+ return {
510
+ handled: true,
511
+ steps: 0
512
+ };
513
+ }
514
+ var segmentCount = this.getChildrenSegmentCount(children);
515
+ var segment = this.buildChildTransitionSegment(children, 0, defaultSteps);
516
+ this.commitImmediateChildTransitionValues(children, segment.values, segment.steps);
517
+ if (!segment.hasSegment || segment.maxSteps === 0) {
518
+ this.commitChildTransitionSegment(children, segment.values, segment.steps);
519
+ delete this.childTargetValues[targetName];
520
+ this.particleValuesDirty = true;
521
+ this.requestParticleRender();
522
+ return {
523
+ handled: true,
524
+ steps: 0
525
+ };
526
+ }
527
+ var transition = {
528
+ children: children,
529
+ segmentIndex: 0,
530
+ segmentCount: segmentCount,
531
+ defaultSteps: defaultSteps,
532
+ initialValues: segment.initialValues,
533
+ values: segment.values,
534
+ steps: segment.steps,
535
+ loops: segment.loops,
536
+ hasLoop: segment.hasLoop,
537
+ generation: this.childGeneration
416
538
  };
539
+ this.childTransitions[targetName] = transition;
417
540
  this.activeChildTransitionKey = key;
541
+ this.addChildTransitionLayoutTargets(transition);
418
542
  if (this.hasDom()) {
419
- this.particleRenderer.setTargetParticles(values, steps).then(function () {
420
- var _this5$childTransitio;
421
- if (((_this5$childTransitio = _this5.childTransitions[targetName]) === null || _this5$childTransitio === void 0 ? void 0 : _this5$childTransitio.values) === values) {
543
+ this.particleRenderer.setTargetParticles(segment.values, segment.steps, transition.generation).then(function (applied) {
544
+ if (applied && _this5.childTransitions[targetName] === transition) {
422
545
  _this5.handleSpecialTargetStep(key);
423
546
  }
424
547
  });
425
548
  }
426
549
  return {
427
550
  handled: true,
428
- steps: maxSteps
551
+ steps: segment.maxSteps
429
552
  };
430
553
  }
554
+ }, {
555
+ key: "commitChildTransitionSegment",
556
+ value: function commitChildTransitionSegment(children, values, steps) {
557
+ var _iterator = _createForOfIteratorHelper(children),
558
+ _step;
559
+ try {
560
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
561
+ var transitionChild = _step.value;
562
+ var index = transitionChild.index;
563
+ var child = this.childHandles[index];
564
+ var childSteps = steps === null || steps === void 0 ? void 0 : steps[index];
565
+ if (!child || !childSteps) {
566
+ continue;
567
+ }
568
+ var layoutChanged = false;
569
+ for (var _i2 = 0, _Object$keys = Object.keys(childSteps); _i2 < _Object$keys.length; _i2++) {
570
+ var _values$index;
571
+ var property = _Object$keys[_i2];
572
+ child.actualValues[property] = (_values$index = values[index]) === null || _values$index === void 0 ? void 0 : _values$index[property];
573
+ if (ParticleUtil.affectsChildLayout(property)) {
574
+ child.removeFromNoDomUpdatingTargets(property);
575
+ layoutChanged = true;
576
+ }
577
+ }
578
+ if (layoutChanged) {
579
+ child.actualValues.isVisible = child.calcVisibility();
580
+ }
581
+ }
582
+ } catch (err) {
583
+ _iterator.e(err);
584
+ } finally {
585
+ _iterator.f();
586
+ }
587
+ }
588
+ }, {
589
+ key: "canBatchChildTarget",
590
+ value: function canBatchChildTarget(property, specification) {
591
+ if (!ParticleUtil.isGpuTarget(property) || !TargetParser.isTargetSpecObject(specification)) {
592
+ return false;
593
+ }
594
+
595
+ // The WebGPU shader interpolates scalar values and colors linearly. Other animation
596
+ // options need ParticleRuntime, which resolves each property's execution separately.
597
+ if (specification.interval !== undefined || specification.easing !== undefined || specification.pauseOn !== undefined || specification.loop !== undefined || specification.cycles !== undefined) {
598
+ return false;
599
+ }
600
+ if (specification.steps !== undefined && (!Number.isFinite(specification.steps) || specification.steps < 0)) {
601
+ return false;
602
+ }
603
+ if (property === "backgroundColor") {
604
+ return typeof specification.value === "string";
605
+ }
606
+ return typeof specification.value === "number" && Number.isFinite(specification.value);
607
+ }
431
608
  }, {
432
609
  key: "handleSpecialTarget",
433
- value: function handleSpecialTarget(key, value) {
434
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
610
+ value: function handleSpecialTarget(key) {
435
611
  if (!this.gpuChildrenEnabled) {
436
612
  return false;
437
613
  }
438
- var targetValues = this.getChildTargetValues(key);
439
- if (targetValues) {
440
- return this.handleChildTargets(key, targetValues, options);
614
+ var targetName = TargetUtil.getTargetName(key);
615
+ var targetValues = this.childTargetValues[targetName];
616
+ if (!targetValues) {
617
+ return false;
618
+ }
619
+ delete this.childTargetValues[targetName];
620
+ for (var index = 0; index < targetValues.length; index++) {
621
+ for (var _i3 = 0, _Object$entries2 = Object.entries(targetValues[index] || {}); _i3 < _Object$entries2.length; _i3++) {
622
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i3], 2),
623
+ property = _Object$entries2$_i[0],
624
+ specification = _Object$entries2$_i[1];
625
+ this.particleRuntime.setImperativeTarget(index, property, specification, undefined, undefined, undefined, key, this);
626
+ }
441
627
  }
442
628
  return false;
443
629
  }
444
630
  }, {
445
631
  key: "getRenderScrollLeft",
446
632
  value: function getRenderScrollLeft() {
447
- var _this$getParent$$dom;
448
- return this.getScrollLeft() || ((_this$getParent$$dom = this.getParent().$dom) === null || _this$getParent$$dom === void 0 ? void 0 : _this$getParent$$dom.getScrollLeft()) || 0;
633
+ var _this$$dom;
634
+ return ((_this$$dom = this.$dom) === null || _this$$dom === void 0 ? void 0 : _this$$dom.getScrollLeft()) || this.getScrollLeft() || 0;
449
635
  }
450
636
  }, {
451
637
  key: "getRenderScrollTop",
452
638
  value: function getRenderScrollTop() {
453
- var _this$getParent$$dom2;
454
- return this.getScrollTop() || ((_this$getParent$$dom2 = this.getParent().$dom) === null || _this$getParent$$dom2 === void 0 ? void 0 : _this$getParent$$dom2.getScrollTop()) || 0;
639
+ var _this$$dom2;
640
+ return ((_this$$dom2 = this.$dom) === null || _this$$dom2 === void 0 ? void 0 : _this$$dom2.getScrollTop()) || this.getScrollTop() || 0;
455
641
  }
456
642
  }, {
457
643
  key: "addChild",
458
644
  value: function addChild(child) {
459
645
  var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.addedChildren.length + this.allChildrenList.length;
460
- if (child && _typeof(child) === "object" && !(child instanceof TModel) && ParticleUtil.isGpuChildrenTarget(TargetUtil.currentTargetName)) {
646
+ if (child && _typeof(child) === "object" && !(child instanceof TModel) && ParticleUtil.isChildrenTarget(TargetUtil.currentTargetName)) {
461
647
  var renderer = this.getChildrenRenderer();
462
648
  if (renderer !== "dom") {
463
649
  var childDefinition = TUtil.cloneTargetDefinition(child);
@@ -472,52 +658,192 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
472
658
  }, {
473
659
  key: "addGpuChild",
474
660
  value: function addGpuChild(definition) {
475
- var key = TargetUtil.currentTargetName;
476
- var targetName = TargetUtil.getTargetName(key);
477
- var index = this.particleValues.length;
661
+ var originalTargetName = TargetUtil.currentTargetName;
662
+ var index = this.childHandles.length;
478
663
  this.gpuChildrenEnabled = true;
479
-
480
- /*
481
- * A placeholder and Child must exist before function-valued properties
482
- * are resolved because functions can call Child getters.
483
- */
484
- this.particleValues[index] = {};
485
- var handle = new Child(this, index);
664
+ var handle = new ParticleChild(this, index);
486
665
  this.childHandles[index] = handle;
666
+ this.childActualValues[index] = handle.actualValues;
667
+ this.childTargetMaps[index] = handle.allTargetMap;
487
668
  try {
488
669
  var _this$pendingGpuChild, _this$pendingGpuChild2;
489
- var compiled = ParticleUtil.compileGpuChildDefinition(handle, definition);
670
+ var compiled = this.prepareInitialGpuChildRuntime(ParticleUtil.compileChildDefinition(handle, definition), definition);
490
671
  var child = this.createGpuChild(compiled.renderDefinition);
491
672
  if (!child) {
492
- this.particleValues.pop();
493
673
  this.childHandles.pop();
674
+ this.childActualValues.pop();
675
+ this.childTargetMaps.pop();
494
676
  return false;
495
677
  }
496
- this.particleValues[index] = child.initial;
497
678
  Object.assign(handle.actualValues, child.initial);
498
- this.particleRuntime.registerChild(index, targetName, compiled);
499
- var pending = (_this$pendingGpuChild2 = (_this$pendingGpuChild = this.pendingGpuChildren)[targetName]) !== null && _this$pendingGpuChild2 !== void 0 ? _this$pendingGpuChild2 : _this$pendingGpuChild[targetName] = {
500
- key: key,
679
+ this.childActualValues[index] = handle.actualValues;
680
+ this.childTargetMaps[index] = handle.allTargetMap;
681
+ this.particleRuntime.registerChild(index, originalTargetName, compiled);
682
+ var pending = (_this$pendingGpuChild2 = (_this$pendingGpuChild = this.pendingGpuChildren)[originalTargetName]) !== null && _this$pendingGpuChild2 !== void 0 ? _this$pendingGpuChild2 : _this$pendingGpuChild[originalTargetName] = {
683
+ key: originalTargetName,
501
684
  children: []
502
685
  };
503
686
  pending.children.push(_objectSpread({
504
687
  index: index
505
688
  }, child));
689
+ this.childGeneration++;
506
690
  this.childrenUpdateFlag = true;
507
691
  this.markLayoutDirty("addGpuChild");
508
692
  return true;
509
693
  } catch (error) {
510
- this.particleValues.pop();
511
694
  this.childHandles.pop();
695
+ this.childActualValues.pop();
696
+ this.childTargetMaps.pop();
512
697
  this.childRuntimePrograms.pop();
513
698
  this.childRuntimeStates.pop();
514
699
  throw error;
515
700
  }
516
701
  }
702
+ }, {
703
+ key: "prepareInitialGpuChildRuntime",
704
+ value: function prepareInitialGpuChildRuntime(compiled, definition) {
705
+ var _loop = function _loop() {
706
+ var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i4], 2),
707
+ key = _Object$entries3$_i[0],
708
+ specification = _Object$entries3$_i[1];
709
+ if (TargetUtil.getTargetName(key) !== key || !TargetParser.isTargetSpecObject(specification) || !ParticleUtil.isGpuTarget(key)) {
710
+ return 0; // continue
711
+ }
712
+ var value = specification.value;
713
+ var hasValues = Array.isArray(value) && value.length > 1;
714
+ var steps = specification.steps;
715
+ var hasSteps = Array.isArray(steps) ? steps.some(function (step) {
716
+ return Number(step) > 0;
717
+ }) : Number(steps) > 0;
718
+ if (!hasValues && !hasSteps) {
719
+ return 0; // continue
720
+ }
721
+
722
+ // Function-valued targets are already compiled for ParticleRuntime.
723
+ if (typeof value === "function") {
724
+ return 0; // continue
725
+ }
726
+ var targetName = ParticleUtil.getTargetName(key);
727
+ var initialValue = TUtil.isDefined(specification.initialValue) ? specification.initialValue : hasValues ? value[0] : value;
728
+ var runtimeTarget = compiled.runtimeTargets.find(function (target) {
729
+ return target.key === key && target.mode === "immediate";
730
+ });
731
+
732
+ // Initial animations belong to the child, not to the parent's GPU transition.
733
+ compiled.renderDefinition[targetName] = initialValue;
734
+ if (runtimeTarget) {
735
+ runtimeTarget.requiresRuntime = true;
736
+ runtimeTarget.requiresInitialResolution = false;
737
+ runtimeTarget.renderable = true;
738
+ runtimeTarget.target = _objectSpread({}, specification);
739
+ } else {
740
+ compiled.runtimeTargets.push({
741
+ key: key,
742
+ targetName: targetName,
743
+ mode: "immediate",
744
+ target: _objectSpread({}, specification),
745
+ requiresRuntime: true,
746
+ requiresInitialResolution: false,
747
+ renderable: true
748
+ });
749
+ }
750
+ },
751
+ _ret;
752
+ for (var _i4 = 0, _Object$entries3 = Object.entries(definition); _i4 < _Object$entries3.length; _i4++) {
753
+ _ret = _loop();
754
+ if (_ret === 0) continue;
755
+ }
756
+ return compiled;
757
+ }
758
+ }, {
759
+ key: "removeChild",
760
+ value: function removeChild(child) {
761
+ if (!this.gpuChildrenEnabled || !(child instanceof ParticleChild)) {
762
+ return _superPropGet(ParticleTModel, "removeChild", this, 3)([child]);
763
+ }
764
+ var index = this.childHandles.indexOf(child);
765
+ if (index < 0) {
766
+ return;
767
+ }
768
+ this.particleRuntime.removeChild(index);
769
+ this.childHandles.splice(index, 1);
770
+ this.childActualValues.splice(index, 1);
771
+ this.childTargetMaps.splice(index, 1);
772
+ this.removeChildFromTransitions(index);
773
+ for (var _i5 = 0, _Object$values = Object.values(this.childTargetValues); _i5 < _Object$values.length; _i5++) {
774
+ var targetValues = _Object$values[_i5];
775
+ targetValues === null || targetValues === void 0 || targetValues.splice(index, 1);
776
+ }
777
+ child.index = -1;
778
+ for (var i = index; i < this.childHandles.length; i++) {
779
+ this.childHandles[i].index = i;
780
+ }
781
+ this.childGeneration++;
782
+ this.particleValuesDirty = true;
783
+ this.invalidateLayout();
784
+ this.markLayoutDirty("removeGpuChild");
785
+ this.requestParticleRender();
786
+ return this;
787
+ }
788
+ }, {
789
+ key: "removeChildFromTransitions",
790
+ value: function removeChildFromTransitions(index) {
791
+ for (var _i6 = 0, _Object$values2 = Object.values(this.childTransitions); _i6 < _Object$values2.length; _i6++) {
792
+ var _transition$initialVa, _transition$values, _transition$steps, _transition$loops;
793
+ var transition = _Object$values2[_i6];
794
+ (_transition$initialVa = transition.initialValues) === null || _transition$initialVa === void 0 || _transition$initialVa.splice(index, 1);
795
+ (_transition$values = transition.values) === null || _transition$values === void 0 || _transition$values.splice(index, 1);
796
+ (_transition$steps = transition.steps) === null || _transition$steps === void 0 || _transition$steps.splice(index, 1);
797
+ (_transition$loops = transition.loops) === null || _transition$loops === void 0 || _transition$loops.splice(index, 1);
798
+ if (transition.children) {
799
+ transition.children = transition.children.filter(function (child) {
800
+ return child.index !== index;
801
+ });
802
+ var _iterator2 = _createForOfIteratorHelper(transition.children),
803
+ _step2;
804
+ try {
805
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
806
+ var child = _step2.value;
807
+ if (child.index > index) {
808
+ child.index--;
809
+ }
810
+ }
811
+ } catch (err) {
812
+ _iterator2.e(err);
813
+ } finally {
814
+ _iterator2.f();
815
+ }
816
+ }
817
+ }
818
+ for (var _i7 = 0, _Object$values3 = Object.values(this.pendingGpuChildren); _i7 < _Object$values3.length; _i7++) {
819
+ var pending = _Object$values3[_i7];
820
+ if (!(pending !== null && pending !== void 0 && pending.children)) {
821
+ continue;
822
+ }
823
+ pending.children = pending.children.filter(function (child) {
824
+ return child.index !== index;
825
+ });
826
+ var _iterator3 = _createForOfIteratorHelper(pending.children),
827
+ _step3;
828
+ try {
829
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
830
+ var _child = _step3.value;
831
+ if (_child.index > index) {
832
+ _child.index--;
833
+ }
834
+ }
835
+ } catch (err) {
836
+ _iterator3.e(err);
837
+ } finally {
838
+ _iterator3.f();
839
+ }
840
+ }
841
+ }
517
842
  }, {
518
843
  key: "isTargetEnabled",
519
844
  value: function isTargetEnabled(key) {
520
- if (ParticleUtil.isGpuChildrenTarget(key) && this.isExecuted(key) && this.particleRuntime.hasPending(key)) {
845
+ var target = this.targets[key];
846
+ if (ParticleUtil.isChildrenTarget(key) && (target === null || target === void 0 ? void 0 : target.waitForChildren) === true && this.isExecuted(key) && this.particleRuntime.hasPending(key)) {
521
847
  return false;
522
848
  }
523
849
  return _superPropGet(ParticleTModel, "isTargetEnabled", this, 3)([key]);
@@ -536,11 +862,11 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
536
862
  var loops = {};
537
863
  var valueLists = {};
538
864
  var hasTransition = false;
539
- for (var _i2 = 0, _Object$entries2 = Object.entries(definition); _i2 < _Object$entries2.length; _i2++) {
865
+ for (var _i8 = 0, _Object$entries4 = Object.entries(definition); _i8 < _Object$entries4.length; _i8++) {
540
866
  var _resolved$valueList;
541
- var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
542
- property = _Object$entries2$_i[0],
543
- value = _Object$entries2$_i[1];
867
+ var _Object$entries4$_i = _slicedToArray(_Object$entries4[_i8], 2),
868
+ property = _Object$entries4$_i[0],
869
+ value = _Object$entries4$_i[1];
544
870
  var resolved = this.resolveInitialChildProperty(value);
545
871
  if (!resolved) {
546
872
  return;
@@ -573,67 +899,133 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
573
899
  key: "finalizeChildrenTarget",
574
900
  value: function finalizeChildrenTarget(key) {
575
901
  var _this6 = this;
576
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
577
- if (!ParticleUtil.isGpuChildrenTarget(key)) {
902
+ if (!ParticleUtil.isChildrenTarget(key) && !TargetParser.isExplodeChildrenTarget(key)) {
578
903
  return false;
579
904
  }
580
- var targetName = TargetUtil.getTargetName(key);
581
- var pending = this.pendingGpuChildren[targetName];
905
+ var pending = this.pendingGpuChildren[key];
582
906
  if (!(pending !== null && pending !== void 0 && pending.children.length)) {
583
907
  return false;
584
908
  }
585
- this.invalidateChildrenLayout();
586
- var defaultSteps = Math.max(0, Number(options.steps) || 0);
587
- var currentValues = this.particleValues;
588
- var segmentCount = this.getChildrenSegmentCount(pending.children);
589
- var segment = this.buildChildTransitionSegment(pending.children, 0, currentValues, defaultSteps);
590
- delete this.pendingGpuChildren[targetName];
591
- if (!segment.hasSegment || segment.maxSteps === 0) {
592
- this.particleValues = segment.values;
593
- var runtimeIndexes = pending.children.map(function (child) {
594
- return child.index;
595
- }).filter(function (index) {
596
- var _this6$childRuntimePr;
597
- return (_this6$childRuntimePr = _this6.childRuntimePrograms[index]) === null || _this6$childRuntimePr === void 0 ? void 0 : _this6$childRuntimePr.length;
598
- });
599
- var _iterator = _createForOfIteratorHelper(runtimeIndexes),
600
- _step;
601
- try {
602
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
603
- var index = _step.value;
604
- this.particleRuntime.queueStart(index);
605
- }
606
- } catch (err) {
607
- _iterator.e(err);
608
- } finally {
609
- _iterator.f();
610
- }
611
- if (this.hasDom()) {
612
- this.particleRenderer.setParticles(segment.values).then(function () {
613
- _this6.particleRuntime.markRenderReady(runtimeIndexes);
614
- });
909
+ this.invalidateLayout();
910
+ delete this.pendingGpuChildren[key];
911
+ var childIndexes = pending.children.map(function (child) {
912
+ return child.index;
913
+ });
914
+ var runtimeIndexes = childIndexes.filter(function (index) {
915
+ var state = _this6.childRuntimeStates[index];
916
+ return state && !state.done;
917
+ });
918
+ var _iterator4 = _createForOfIteratorHelper(runtimeIndexes),
919
+ _step4;
920
+ try {
921
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
922
+ var index = _step4.value;
923
+ this.particleRuntime.queueStart(index);
615
924
  }
616
- return {
617
- handled: true,
618
- steps: 0
619
- };
925
+ } catch (err) {
926
+ _iterator4.e(err);
927
+ } finally {
928
+ _iterator4.f();
929
+ }
930
+ if (this.hasDom()) {
931
+ var particlesReady = this.particleRenderer.setParticles(this.childHandles);
932
+ var renderReady = TargetParser.isExplodeChildrenTarget(key) && this.explodeCapturePromise ? Promise.all([particlesReady, this.explodeCapturePromise]) : Promise.all([particlesReady]);
933
+ renderReady.then(function (results) {
934
+ if (results.some(function (result) {
935
+ return result !== true;
936
+ })) {
937
+ return;
938
+ }
939
+ _this6.particleRuntime.markRenderReady(childIndexes);
940
+ }).catch(function (error) {
941
+ return console.error(error);
942
+ });
620
943
  }
621
- this.childTransitions[targetName] = {
622
- children: pending.children,
623
- segmentIndex: 0,
624
- segmentCount: segmentCount,
625
- defaultSteps: defaultSteps,
626
- values: segment.values,
627
- steps: segment.steps,
628
- loops: segment.loops,
629
- hasLoop: segment.hasLoop
630
- };
631
- this.activeChildTransitionKey = key;
632
944
  return {
633
945
  handled: true,
634
- steps: segment.maxSteps
946
+ steps: 0
635
947
  };
636
948
  }
949
+ }, {
950
+ key: "addChildTransitionLayoutTargets",
951
+ value: function addChildTransitionLayoutTargets(transition) {
952
+ var _iterator5 = _createForOfIteratorHelper(transition.children),
953
+ _step5;
954
+ try {
955
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
956
+ var _transition$steps2;
957
+ var transitionChild = _step5.value;
958
+ var index = transitionChild.index;
959
+ var child = this.childHandles[index];
960
+ var childSteps = (_transition$steps2 = transition.steps) === null || _transition$steps2 === void 0 ? void 0 : _transition$steps2[index];
961
+ if (!child || !childSteps) {
962
+ continue;
963
+ }
964
+ for (var _i9 = 0, _Object$entries5 = Object.entries(childSteps); _i9 < _Object$entries5.length; _i9++) {
965
+ var _Object$entries5$_i = _slicedToArray(_Object$entries5[_i9], 2),
966
+ property = _Object$entries5$_i[0],
967
+ steps = _Object$entries5$_i[1];
968
+ if (steps > 0 && ParticleUtil.affectsChildLayout(property)) {
969
+ child.addToNoDomUpdatingTargets(property);
970
+ }
971
+ }
972
+ }
973
+ } catch (err) {
974
+ _iterator5.e(err);
975
+ } finally {
976
+ _iterator5.f();
977
+ }
978
+ }
979
+ }, {
980
+ key: "catchupChildLayoutTargets",
981
+ value: function catchupChildLayoutTargets(child) {
982
+ var _child$noDomUpdatingT, _transition$initialVa2, _transition$values2, _transition$steps3;
983
+ if (!(child !== null && child !== void 0 && (_child$noDomUpdatingT = child.noDomUpdatingTargets) !== null && _child$noDomUpdatingT !== void 0 && _child$noDomUpdatingT.size) || child.index < 0) {
984
+ return false;
985
+ }
986
+ var key = this.activeChildTransitionKey;
987
+ if (!key) {
988
+ return false;
989
+ }
990
+ var targetName = TargetUtil.getTargetName(key);
991
+ var transition = this.childTransitions[targetName];
992
+ if (!transition || transition.generation !== this.childGeneration) {
993
+ return false;
994
+ }
995
+ var index = child.index;
996
+ var initialValues = (_transition$initialVa2 = transition.initialValues) === null || _transition$initialVa2 === void 0 ? void 0 : _transition$initialVa2[index];
997
+ var targetValues = (_transition$values2 = transition.values) === null || _transition$values2 === void 0 ? void 0 : _transition$values2[index];
998
+ var childSteps = (_transition$steps3 = transition.steps) === null || _transition$steps3 === void 0 ? void 0 : _transition$steps3[index];
999
+ if (!initialValues || !targetValues || !childSteps) {
1000
+ return false;
1001
+ }
1002
+ var currentStep = Math.max(0, Number(this.getTargetStep(key)) || 0);
1003
+ var changed = false;
1004
+ for (var _i10 = 0, _arr = _toConsumableArray(child.noDomUpdatingTargets); _i10 < _arr.length; _i10++) {
1005
+ var property = _arr[_i10];
1006
+ if (!ParticleUtil.affectsChildLayout(property)) {
1007
+ child.removeFromNoDomUpdatingTargets(property);
1008
+ continue;
1009
+ }
1010
+ var initialValue = initialValues[property];
1011
+ var targetValue = targetValues[property];
1012
+ var steps = Math.max(0, Number(childSteps[property]) || 0);
1013
+ if (!TUtil.isDefined(initialValue) || !TUtil.isDefined(targetValue)) {
1014
+ child.removeFromNoDomUpdatingTargets(property);
1015
+ continue;
1016
+ }
1017
+ var progress = steps === 0 ? 1 : Math.min(1, currentStep / steps);
1018
+ var value = initialValue + (targetValue - initialValue) * progress;
1019
+ if (child.actualValues[property] !== value) {
1020
+ child.actualValues[property] = value;
1021
+ changed = true;
1022
+ }
1023
+ if (progress === 1) {
1024
+ child.removeFromNoDomUpdatingTargets(property);
1025
+ }
1026
+ }
1027
+ return changed;
1028
+ }
637
1029
  }, {
638
1030
  key: "advanceChildTransitionSegment",
639
1031
  value: function advanceChildTransitionSegment(key, transition) {
@@ -645,13 +1037,16 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
645
1037
  if (nextSegmentIndex >= transition.segmentCount) {
646
1038
  return false;
647
1039
  }
648
- this.particleValues = transition.values;
1040
+ this.commitChildTransitionSegment(transition.children, transition.values, transition.steps);
649
1041
  this.particleRenderer.completeTransition();
650
- var segment = this.buildChildTransitionSegment(transition.children, nextSegmentIndex, this.particleValues, transition.defaultSteps);
1042
+ var segment = this.buildChildTransitionSegment(transition.children, nextSegmentIndex, transition.defaultSteps);
651
1043
  transition.segmentIndex = nextSegmentIndex;
1044
+ transition.initialValues = segment.initialValues;
652
1045
  transition.values = segment.values;
653
1046
  transition.steps = segment.steps;
654
1047
  transition.loops = segment.loops;
1048
+ this.commitImmediateChildTransitionValues(transition.children, segment.values, segment.steps);
1049
+ this.addChildTransitionLayoutTargets(transition);
655
1050
  var targetValue = this.targetValues[key];
656
1051
  if (targetValue) {
657
1052
  targetValue.steps = segment.maxSteps;
@@ -660,8 +1055,8 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
660
1055
  this.resetTargetInitialValue(key);
661
1056
  this.setTargetStatus(key, "updating");
662
1057
  if (this.hasDom()) {
663
- this.particleRenderer.setTargetParticles(segment.values, segment.steps).then(function () {
664
- if (_this7.childTransitions[TargetUtil.getTargetName(key)] === transition) {
1058
+ this.particleRenderer.setTargetParticles(segment.values, segment.steps, transition.generation).then(function (applied) {
1059
+ if (applied && _this7.childTransitions[TargetUtil.getTargetName(key)] === transition) {
665
1060
  _this7.handleSpecialTargetStep(key);
666
1061
  }
667
1062
  });
@@ -670,69 +1065,78 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
670
1065
  }
671
1066
  }, {
672
1067
  key: "buildChildTransitionSegment",
673
- value: function buildChildTransitionSegment(children, segmentIndex, currentValues, defaultSteps) {
674
- var values = currentValues.map(function (value) {
675
- return _objectSpread({}, value);
676
- });
677
- var steps = Array.from({
678
- length: currentValues.length
679
- }, function () {
680
- return {};
681
- });
682
- var loops = Array.from({
683
- length: currentValues.length
684
- }, function () {
685
- return {};
1068
+ value: function buildChildTransitionSegment(children, segmentIndex, defaultSteps) {
1069
+ var initialValues = new Array(this.childHandles.length);
1070
+ var values = this.childHandles.map(function (child) {
1071
+ return child === null || child === void 0 ? void 0 : child.actualValues;
686
1072
  });
1073
+ var steps = new Array(this.childHandles.length);
1074
+ var loops = new Array(this.childHandles.length);
687
1075
  var maxSteps = 0;
688
1076
  var hasSegment = false;
689
1077
  var hasLoop = false;
690
- var _iterator2 = _createForOfIteratorHelper(children),
691
- _step2;
1078
+ var _iterator6 = _createForOfIteratorHelper(children),
1079
+ _step6;
692
1080
  try {
693
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
694
- var child = _step2.value;
695
- var current = currentValues[child.index];
696
- var target = _objectSpread({}, current);
697
- for (var _i3 = 0, _Object$keys = Object.keys(child.target); _i3 < _Object$keys.length; _i3++) {
698
- var property = _Object$keys[_i3];
699
- var valueList = child.valueLists[property];
1081
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
1082
+ var transitionChild = _step6.value;
1083
+ var index = transitionChild.index;
1084
+ var child = this.childHandles[index];
1085
+ if (!child) {
1086
+ continue;
1087
+ }
1088
+ var current = _objectSpread(_objectSpread({}, child.actualValues), {}, {
1089
+ x: this.getChildValue(index, "x"),
1090
+ y: this.getChildValue(index, "y")
1091
+ });
1092
+ var initial = void 0;
1093
+ var target = void 0;
1094
+ var childSteps = void 0;
1095
+ var childLoops = void 0;
1096
+ for (var _i11 = 0, _Object$keys2 = Object.keys(transitionChild.target); _i11 < _Object$keys2.length; _i11++) {
1097
+ var property = _Object$keys2[_i11];
1098
+ var valueList = transitionChild.valueLists[property];
1099
+ var value = void 0;
700
1100
  if (valueList) {
701
1101
  if (segmentIndex >= valueList.length - 1) {
702
1102
  continue;
703
1103
  }
704
- target[property] = valueList[segmentIndex + 1];
705
- var _propertySteps = this.getChildPropertySteps(child, property, segmentIndex, defaultSteps);
706
- steps[child.index][property] = _propertySteps;
707
- loops[child.index][property] = child.loops[property] === true;
708
- maxSteps = Math.max(maxSteps, _propertySteps);
709
- hasSegment = true;
710
- if (child.loops[property]) {
711
- hasLoop = true;
1104
+ value = valueList[segmentIndex + 1];
1105
+ } else {
1106
+ if (segmentIndex !== 0 || current[property] === transitionChild.target[property]) {
1107
+ continue;
712
1108
  }
713
- continue;
714
- }
715
- if (segmentIndex !== 0 || current[property] === child.target[property]) {
716
- continue;
1109
+ value = transitionChild.target[property];
717
1110
  }
718
- target[property] = child.target[property];
719
- var propertySteps = this.getChildPropertySteps(child, property, segmentIndex, defaultSteps);
720
- steps[child.index][property] = propertySteps;
721
- loops[child.index][property] = child.loops[property] === true;
1111
+ var propertySteps = this.getChildPropertySteps(transitionChild, property, segmentIndex, defaultSteps);
1112
+ initial || (initial = {});
1113
+ target || (target = _objectSpread({}, current));
1114
+ childSteps || (childSteps = {});
1115
+ childLoops || (childLoops = {});
1116
+ initial[property] = current[property];
1117
+ target[property] = value;
1118
+ childSteps[property] = propertySteps;
1119
+ childLoops[property] = transitionChild.loops[property] === true;
722
1120
  maxSteps = Math.max(maxSteps, propertySteps);
723
1121
  hasSegment = true;
724
- if (child.loops[property]) {
1122
+ if (childLoops[property]) {
725
1123
  hasLoop = true;
726
1124
  }
727
1125
  }
728
- values[child.index] = target;
1126
+ if (target) {
1127
+ initialValues[index] = initial;
1128
+ values[index] = target;
1129
+ steps[index] = childSteps;
1130
+ loops[index] = childLoops;
1131
+ }
729
1132
  }
730
1133
  } catch (err) {
731
- _iterator2.e(err);
1134
+ _iterator6.e(err);
732
1135
  } finally {
733
- _iterator2.f();
1136
+ _iterator6.f();
734
1137
  }
735
1138
  return {
1139
+ initialValues: initialValues,
736
1140
  values: values,
737
1141
  steps: steps,
738
1142
  loops: loops,
@@ -757,8 +1161,8 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
757
1161
  key: "getChildSegmentCount",
758
1162
  value: function getChildSegmentCount(child) {
759
1163
  var count = 0;
760
- for (var _i4 = 0, _Object$values = Object.values(child.valueLists); _i4 < _Object$values.length; _i4++) {
761
- var valueList = _Object$values[_i4];
1164
+ for (var _i12 = 0, _Object$values4 = Object.values(child.valueLists); _i12 < _Object$values4.length; _i12++) {
1165
+ var valueList = _Object$values4[_i12];
762
1166
  count = Math.max(count, valueList.length - 1);
763
1167
  }
764
1168
  return count;
@@ -767,17 +1171,17 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
767
1171
  key: "getChildrenSegmentCount",
768
1172
  value: function getChildrenSegmentCount(children) {
769
1173
  var count = 0;
770
- var _iterator3 = _createForOfIteratorHelper(children),
771
- _step3;
1174
+ var _iterator7 = _createForOfIteratorHelper(children),
1175
+ _step7;
772
1176
  try {
773
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
774
- var child = _step3.value;
1177
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
1178
+ var child = _step7.value;
775
1179
  count = Math.max(count, this.getChildSegmentCount(child));
776
1180
  }
777
1181
  } catch (err) {
778
- _iterator3.e(err);
1182
+ _iterator7.e(err);
779
1183
  } finally {
780
- _iterator3.f();
1184
+ _iterator7.f();
781
1185
  }
782
1186
  return count;
783
1187
  }
@@ -794,10 +1198,13 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
794
1198
  key: "handleSpecialTargetStep",
795
1199
  value: function handleSpecialTargetStep(key) {
796
1200
  var targetName = TargetUtil.getTargetName(key);
797
- if (!this.childTransitions[targetName]) {
1201
+ var transition = this.childTransitions[targetName];
1202
+ if (!transition || transition.generation !== this.childGeneration) {
798
1203
  return false;
799
1204
  }
800
- this.particleRenderer.setTransitionStep(this.getTargetStep(key));
1205
+ if (this.isVisible()) {
1206
+ this.particleRenderer.setTransitionStep(this.getTargetStep(key));
1207
+ }
801
1208
  return true;
802
1209
  }
803
1210
  }, {
@@ -808,6 +1215,17 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
808
1215
  if (!transition) {
809
1216
  return false;
810
1217
  }
1218
+ if (transition.generation !== this.childGeneration) {
1219
+ this.particleRenderer.completeTransition();
1220
+ delete this.childTransitions[targetName];
1221
+ delete this.childTargetValues[targetName];
1222
+ if (this.activeChildTransitionKey === key) {
1223
+ this.activeChildTransitionKey = undefined;
1224
+ }
1225
+ this.particleValuesDirty = true;
1226
+ this.requestParticleRender();
1227
+ return true;
1228
+ }
811
1229
  if (this.advanceChildTransitionSegment(key, transition)) {
812
1230
  return true;
813
1231
  }
@@ -815,7 +1233,7 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
815
1233
  this.restartChildTransition(key, transition);
816
1234
  return true;
817
1235
  }
818
- this.particleValues = transition.values;
1236
+ this.commitChildTransitionSegment(transition.children, transition.values, transition.steps);
819
1237
  this.particleRenderer.completeTransition();
820
1238
  delete this.childTransitions[targetName];
821
1239
  delete this.childTargetValues[targetName];
@@ -870,16 +1288,25 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
870
1288
  this.resetTargetStep(key);
871
1289
  this.resetTargetInitialValue(key);
872
1290
  this.setTargetStatus(key, "updating");
1291
+ this.addChildTransitionLayoutTargets(transition);
873
1292
  this.handleSpecialTargetStep(key);
874
1293
  return true;
875
1294
  }
1295
+ }, {
1296
+ key: "shouldBeBracketed",
1297
+ value: function shouldBeBracketed() {
1298
+ if (this.gpuChildrenEnabled) {
1299
+ return false;
1300
+ }
1301
+ return _superPropGet(ParticleTModel, "shouldBeBracketed", this, 3)([]);
1302
+ }
876
1303
  }, {
877
1304
  key: "shouldCalculateChildren",
878
1305
  value: function shouldCalculateChildren() {
879
1306
  if (!this.gpuChildrenEnabled) {
880
1307
  return _superPropGet(ParticleTModel, "shouldCalculateChildren", this, 3)([]);
881
1308
  }
882
- if (this.completeLayoutEpoch === this.layoutEpoch && !this.hasChildrenLayoutStateChanged()) {
1309
+ if (!this.getDirtyLayout() && this.completeLayoutEpoch === this.layoutEpoch && !this.hasLayoutStateChanged()) {
883
1310
  this.currentStatus = undefined;
884
1311
  this.requestParticleRender();
885
1312
  return false;
@@ -887,8 +1314,8 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
887
1314
  return _superPropGet(ParticleTModel, "shouldCalculateChildren", this, 3)([]);
888
1315
  }
889
1316
  }, {
890
- key: "getChildrenLayoutState",
891
- value: function getChildrenLayoutState() {
1317
+ key: "getLayoutState",
1318
+ value: function getLayoutState() {
892
1319
  return [this.getWidth(), this.getHeight(), this.val("gap"), this.getPaddingTop(), this.getPaddingRight(), this.getPaddingBottom(), this.getPaddingLeft(), this.getContainerOverflowMode()];
893
1320
  }
894
1321
  }, {
@@ -899,11 +1326,15 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
899
1326
  return;
900
1327
  }
901
1328
  this.completeLayoutEpoch = epoch;
902
- this.completeChildrenLayoutState = this.getChildrenLayoutState();
903
- if (this.particleRuntime.resolveLayoutFunctions()) {
1329
+ this.completeLayoutState = this.getLayoutState();
1330
+ if (this.particleRuntime.resolveInitialTargets()) {
904
1331
  this.requestParticleRender();
905
- return;
1332
+ if (this.completeLayoutEpoch !== this.layoutEpoch) {
1333
+ getRunScheduler().schedule(0, "particleInitialTargets-".concat(this.oid));
1334
+ return;
1335
+ }
906
1336
  }
1337
+ this.particleRenderer.updateCanvasLayerWidthHeight();
907
1338
  this.resolveLayoutCompleteWaiters();
908
1339
  this.particleRuntime.startReady();
909
1340
  var key = this.activeChildTransitionKey;
@@ -915,25 +1346,102 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
915
1346
  if (!transition) {
916
1347
  return;
917
1348
  }
918
- transition.values = transition.values.map(function (target, index) {
919
- return _objectSpread(_objectSpread({}, _this8.particleValues[index]), target);
920
- });
921
- if (this.restoringParticleRuntime || !this.hasDom()) {
1349
+ var layoutProperties = ["x", "y", "width", "height"];
1350
+ for (var index = 0; index < this.childHandles.length; index++) {
1351
+ var _transition$steps4, _index, _transition$steps4$_i;
1352
+ var child = this.childHandles[index];
1353
+ if (!child) {
1354
+ continue;
1355
+ }
1356
+ var target = transition.values[index];
1357
+ if (!target || target === child.actualValues) {
1358
+ target = _objectSpread({}, child.actualValues);
1359
+ transition.values[index] = target;
1360
+ }
1361
+ var childSteps = (_transition$steps4$_i = (_transition$steps4 = transition.steps)[_index = index]) !== null && _transition$steps4$_i !== void 0 ? _transition$steps4$_i : _transition$steps4[_index] = {};
1362
+ var _iterator8 = _createForOfIteratorHelper(layoutProperties),
1363
+ _step8;
1364
+ try {
1365
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
1366
+ var property = _step8.value;
1367
+ if (Object.prototype.hasOwnProperty.call(childSteps, property)) {
1368
+ continue;
1369
+ }
1370
+ var value = this.getChildValue(index, property);
1371
+ if (!TUtil.isDefined(value)) {
1372
+ continue;
1373
+ }
1374
+ target[property] = value;
1375
+ childSteps[property] = 0;
1376
+ }
1377
+ } catch (err) {
1378
+ _iterator8.e(err);
1379
+ } finally {
1380
+ _iterator8.f();
1381
+ }
1382
+ }
1383
+ if (transition.generation !== this.childGeneration || this.restoringParticleRuntime || !this.hasDom()) {
922
1384
  return;
923
1385
  }
924
- this.particleRenderer.setParticles(this.particleValues).then(function () {
925
- return _this8.particleRenderer.setTargetParticles(transition.values, transition.steps);
926
- }).then(function () {
927
- if (_this8.childTransitions[targetName] === transition) {
1386
+ var isCurrentTransition = function isCurrentTransition() {
1387
+ return _this8.activeChildTransitionKey === key && _this8.childTransitions[targetName] === transition && transition.generation === _this8.childGeneration;
1388
+ };
1389
+ this.particleRenderer.setTargetParticles(transition.values, transition.steps, transition.generation).then(function (applied) {
1390
+ if (applied && isCurrentTransition()) {
928
1391
  _this8.handleSpecialTargetStep(key);
929
1392
  }
930
1393
  });
931
1394
  }
932
1395
  }, {
933
- key: "hasChildrenLayoutStateChanged",
934
- value: function hasChildrenLayoutStateChanged() {
935
- var current = this.getChildrenLayoutState();
936
- var previous = this.completeChildrenLayoutState;
1396
+ key: "commitImmediateChildTransitionValues",
1397
+ value: function commitImmediateChildTransitionValues(children, values, steps) {
1398
+ var changed = false;
1399
+ var _iterator9 = _createForOfIteratorHelper(children),
1400
+ _step9;
1401
+ try {
1402
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
1403
+ var transitionChild = _step9.value;
1404
+ var index = transitionChild.index;
1405
+ var child = this.childHandles[index];
1406
+ var childSteps = steps === null || steps === void 0 ? void 0 : steps[index];
1407
+ if (!child || !childSteps) {
1408
+ continue;
1409
+ }
1410
+ var layoutChanged = false;
1411
+ for (var _i13 = 0, _Object$entries6 = Object.entries(childSteps); _i13 < _Object$entries6.length; _i13++) {
1412
+ var _values$index2;
1413
+ var _Object$entries6$_i = _slicedToArray(_Object$entries6[_i13], 2),
1414
+ property = _Object$entries6$_i[0],
1415
+ propertySteps = _Object$entries6$_i[1];
1416
+ if (propertySteps !== 0) {
1417
+ continue;
1418
+ }
1419
+ var value = (_values$index2 = values[index]) === null || _values$index2 === void 0 ? void 0 : _values$index2[property];
1420
+ if (child.actualValues[property] === value) {
1421
+ continue;
1422
+ }
1423
+ child.actualValues[property] = value;
1424
+ changed = true;
1425
+ if (ParticleUtil.affectsChildLayout(property)) {
1426
+ layoutChanged = true;
1427
+ }
1428
+ }
1429
+ if (layoutChanged) {
1430
+ child.actualValues.isVisible = child.calcVisibility();
1431
+ }
1432
+ }
1433
+ } catch (err) {
1434
+ _iterator9.e(err);
1435
+ } finally {
1436
+ _iterator9.f();
1437
+ }
1438
+ return changed;
1439
+ }
1440
+ }, {
1441
+ key: "hasLayoutStateChanged",
1442
+ value: function hasLayoutStateChanged() {
1443
+ var current = this.getLayoutState();
1444
+ var previous = this.completeLayoutState;
937
1445
  if (!previous || current.length !== previous.length) {
938
1446
  return true;
939
1447
  }
@@ -942,14 +1450,33 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
942
1450
  });
943
1451
  }
944
1452
  }, {
945
- key: "invalidateChildrenLayout",
946
- value: function invalidateChildrenLayout() {
1453
+ key: "invalidateLayout",
1454
+ value: function invalidateLayout() {
947
1455
  this.layoutEpoch++;
948
1456
  }
949
1457
  }, {
950
1458
  key: "getParticleCount",
951
1459
  value: function getParticleCount() {
952
- return this.particleValues.length;
1460
+ return this.childHandles.length;
1461
+ }
1462
+ }, {
1463
+ key: "getRuntimeSnapshotFields",
1464
+ value: function getRuntimeSnapshotFields() {
1465
+ return {
1466
+ childHandleRuntimeStates: this.childHandles.map(function (child) {
1467
+ return {
1468
+ x: child.x,
1469
+ y: child.y,
1470
+ targets: child.targets,
1471
+ targetValues: child.targetValues,
1472
+ updatingTargetList: _toConsumableArray(child.updatingTargetList),
1473
+ activeTargetList: _toConsumableArray(child.activeTargetList),
1474
+ activatedTargets: _toConsumableArray(child.activatedTargets),
1475
+ noDomUpdatingTargets: child.noDomUpdatingTargets ? new Set(child.noDomUpdatingTargets) : undefined,
1476
+ pendingTargets: child.pendingTargets
1477
+ };
1478
+ })
1479
+ };
953
1480
  }
954
1481
  }, {
955
1482
  key: "excludeRuntimeSnapshotField",
@@ -960,15 +1487,53 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
960
1487
  key: "restoreRuntimeDerivedState",
961
1488
  value: function restoreRuntimeDerivedState() {
962
1489
  var _this9 = this;
963
- this.childHandles = this.particleValues.map(function (value, index) {
964
- return new Child(_this9, index);
1490
+ this.particleRenderer.destroy();
1491
+ this.childActualValues || (this.childActualValues = []);
1492
+ this.childTargetMaps || (this.childTargetMaps = []);
1493
+ var childHandleRuntimeStates = this.childHandleRuntimeStates || [];
1494
+ this.childHandles = this.childActualValues.map(function (values, index) {
1495
+ var _runtimeState$x, _runtimeState$y;
1496
+ var child = new ParticleChild(_this9, index);
1497
+ var targetMap = _this9.childTargetMaps[index] || {};
1498
+ var runtimeState = childHandleRuntimeStates[index];
1499
+ Object.assign(child.actualValues, values);
1500
+ Object.assign(child.allTargetMap, targetMap);
1501
+ child.x = (_runtimeState$x = runtimeState === null || runtimeState === void 0 ? void 0 : runtimeState.x) !== null && _runtimeState$x !== void 0 ? _runtimeState$x : child.x;
1502
+ child.y = (_runtimeState$y = runtimeState === null || runtimeState === void 0 ? void 0 : runtimeState.y) !== null && _runtimeState$y !== void 0 ? _runtimeState$y : child.y;
1503
+ if (runtimeState) {
1504
+ var _child$activeTargetLi, _child$activatedTarge, _runtimeState$pending;
1505
+ Object.assign(child.targets, runtimeState.targets);
1506
+ Object.assign(child.targetValues, runtimeState.targetValues);
1507
+ var _iterator10 = _createForOfIteratorHelper(runtimeState.updatingTargetList || []),
1508
+ _step10;
1509
+ try {
1510
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
1511
+ var key = _step10.value;
1512
+ child.updatingTargetList.push(key);
1513
+ child.updatingTargetMap[key] = true;
1514
+ }
1515
+ } catch (err) {
1516
+ _iterator10.e(err);
1517
+ } finally {
1518
+ _iterator10.f();
1519
+ }
1520
+ (_child$activeTargetLi = child.activeTargetList).push.apply(_child$activeTargetLi, _toConsumableArray(runtimeState.activeTargetList || []));
1521
+ (_child$activatedTarge = child.activatedTargets).push.apply(_child$activatedTarge, _toConsumableArray(runtimeState.activatedTargets || []));
1522
+ child.noDomUpdatingTargets = runtimeState.noDomUpdatingTargets ? new Set(runtimeState.noDomUpdatingTargets) : undefined;
1523
+ child.pendingTargets = (_runtimeState$pending = runtimeState.pendingTargets) !== null && _runtimeState$pending !== void 0 ? _runtimeState$pending : false;
1524
+ }
1525
+ _this9.childActualValues[index] = child.actualValues;
1526
+ _this9.childTargetMaps[index] = child.allTargetMap;
1527
+ return child;
965
1528
  });
1529
+ delete this.childHandleRuntimeStates;
1530
+ this.childGeneration = Number.isInteger(this.childGeneration) ? this.childGeneration : 0;
966
1531
  this.particleValuesDirty = false;
967
1532
  this.particleRenderRequested = false;
968
1533
  this.pendingGpuChildren = {};
969
1534
  this.layoutEpoch = 0;
970
- this.completeLayoutEpoch = 0;
971
- this.completeChildrenLayoutState = this.getChildrenLayoutState();
1535
+ this.completeLayoutEpoch = -1;
1536
+ this.completeLayoutState = undefined;
972
1537
  this.layoutCompleteWaiters = [];
973
1538
  this.particleSyncPromise = undefined;
974
1539
  this.restoringParticleRuntime = true;
@@ -991,17 +1556,17 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
991
1556
  key: "resolveLayoutCompleteWaiters",
992
1557
  value: function resolveLayoutCompleteWaiters() {
993
1558
  var waiters = this.layoutCompleteWaiters.splice(0);
994
- var _iterator4 = _createForOfIteratorHelper(waiters),
995
- _step4;
1559
+ var _iterator11 = _createForOfIteratorHelper(waiters),
1560
+ _step11;
996
1561
  try {
997
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
998
- var resolve = _step4.value;
1562
+ for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
1563
+ var resolve = _step11.value;
999
1564
  resolve();
1000
1565
  }
1001
1566
  } catch (err) {
1002
- _iterator4.e(err);
1567
+ _iterator11.e(err);
1003
1568
  } finally {
1004
- _iterator4.f();
1569
+ _iterator11.f();
1005
1570
  }
1006
1571
  }
1007
1572
  }]);
@@ -1010,11 +1575,17 @@ function isParticleTModel(targets) {
1010
1575
  if (!targets) {
1011
1576
  return false;
1012
1577
  }
1013
- for (var _i5 = 0, _Object$entries3 = Object.entries(targets); _i5 < _Object$entries3.length; _i5++) {
1014
- var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i5], 2),
1015
- key = _Object$entries3$_i[0],
1016
- target = _Object$entries3$_i[1];
1017
- if (!ParticleUtil.isGpuChildrenTarget(key)) {
1578
+ for (var _i14 = 0, _Object$entries7 = Object.entries(targets); _i14 < _Object$entries7.length; _i14++) {
1579
+ var _Object$entries7$_i = _slicedToArray(_Object$entries7[_i14], 2),
1580
+ key = _Object$entries7$_i[0],
1581
+ target = _Object$entries7$_i[1];
1582
+ if (TargetParser.isExplodeChildrenTarget(key)) {
1583
+ if ((target === null || target === void 0 ? void 0 : target.renderer) !== "dom") {
1584
+ return true;
1585
+ }
1586
+ continue;
1587
+ }
1588
+ if (!ParticleUtil.isChildrenTarget(key)) {
1018
1589
  continue;
1019
1590
  }
1020
1591
  if (!target || _typeof(target) !== "object") {